I'am following this tutorial http://welcometothebundle.com/web-api-rest-with-symfony2-the-best-way-the-post-method/, but I have a client in angularjs and a rest API with symfony.
My problem is I still don't know how can I send the data from my form in angularjs to symfony2's controller then to database Mysql.
update: I know how to add data statically in Client controller to database,but how to do it with values from th angularjs form
public function insertAction()
{
$client = new Client();
$client->setName('cccccccc');
$client->setAdress('ffffffff');
$client->setCivilit('sssssssss');
$em = $this->getDoctrine()->getManager();
$em->persist($client);
$em->flush();
return new Response('Id du client créé : '.$client->getId());
and this is app.js in which I define the controller:
.controller('PostsCtrlAjax1', ['$scope', '$http' ,function($scope,$http) {
$http({method: 'POST', url: 'http://localhost/operation/web/app_dev.php/apiclient/insertcl.json'})
.success(function(data){
$scope.posts = data; // response data
}).error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
console.log("data error ...");
});
}]);
when I run my client angularjs,the static data will be stocked in the database Any idea please and thanks for help.