1

I want to call a php method using angular service. I do this :

 save:function(){
              var req = {
                  method: "GET",
                  url: "/api/save/",
                  data: {
                      nom:"nom"
                  }
              }
              var deferred = $q.defer();
              $http(req).
                  success(function(result) {
                      console.log(req);
                      deferred.resolve(result);
                  })

and in my php controller :

 public function savePersonnelAction(Request $httpRequest){

        $content= $httpRequest->query->get('data');
 return $this->render('clientBundle:Default:index.html.twig',array('content'=>$content));
}

But I have an empty object as a result.

Can someone help me to resolve this problem please

0

2 Answers 2

1

Do you only want to send some data in a query string?

For a GET request, you should use params, not data attribute.

data is used for a POST request content.

Sign up to request clarification or add additional context in comments.

Comments

0

Try like this:

 $content= $httpRequest->query->get('nom');

Cheers

5 Comments

I have nullas result
null where? In your view?
Yes in the view. But I see the result in the debbuger
So, your angular service seems to be the suspect one.
As Mateusz said you have to use params for get request: ... params: { nom:"nom" ... }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.