javascript - How to pass in a JSON object to a resource in angularjs -


i use web-service takes in json object (the object binds 2 arrays) in post request , returns json object array.

i send request webservice angularjs. here code:

wellapp.factory('search', ['$resource',function($resource){      return $resource('/filetables/searchdata/:tagsearchinput',             {             },             {                 searchdata:{                     method:'post',                     isarray: true,                     params:{ tag: '@tagsearchinput.tag',                             details: '@tagsearchinput.details'                     }                 }             })  }])   function mywellsctrl($scope,$resource, wells, tags, search) {      $scope.wellsearchresult = search.searchdata({tag: ["typeofwell"],                                                  details: ["vertical"]}); }; 

if this, nullpointerexception @ server side, meaning arguments pass getting passed null.

how pass in object such server interprets them object containing 2 arrays. i'm new angularjs , not able understand @ notation of assigning incoming parameter. it'd great if here can lend me help.

you shouldn't need include params in searchdata since json sent in body of post request. try removing them searchdata. in controller, try calling service this:

search.searchdata({}, {tag: ["typeofwell"], details: ["vertical"]}) 

note {} first parameter, params request. second {} payload. send json in request payload instead of params. let me know if doesn't work you. have done similar you're doing , way worked me.


Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -