AngularJS - $http.post send data as json

后端 未结 3 1795
野的像风
野的像风 2020-12-05 06:19

I\'m working on autocomplete directive with angularjs but having some issues.

I have a form which have an autocomplete input. When i type something there, the

3条回答
  •  萌比男神i
    2020-12-05 07:12

    i think the most proper way is to use the same piece of code angular use when doing a "get" request using you $httpParamSerializer will have to inject it to your controller so you can simply do the following without having to use Jquery at all , $http.post(url,$httpParamSerializer({param:val}))

    app.controller('ctrl',function($scope,$http,$httpParamSerializer){
      $http.post(url,$httpParamSerializer({param:val,secondParam:secondVal}));
    }
    

提交回复
热议问题