javascript - How to set request body and params on $resource POST -


i'm attempting pass data in request body , request parameter angular $resource call. below click handler controller , service calls:

controller.js:

vm.setlimit = function(limit) {   var data = {     activity: 'point_limit',     limit: limit   };   playersservice.setplayerlimit({     playerid: playerid,     data   }); }; 

service.js:

angular.module('gameapp')   .factory('playersservice', ['$resource',     function($resource) {       var base = '/api/players/:playerid/';       return $resource(base, {}, {         getplayerinfo: {method: 'get', url: base + 'playerinfo'},         setplayerlimit: {method: 'post', url: base + 'playerlimit'}       });     }]); 

getplayerinfo works, setplayerlimit not because, reason, not being passed playerid.

playersservice.setplayerlimit should take 4 parameters in order:

(request parameters, request body, success callback, error callback)

modify code as:

playersservice.setplayerlimit({playerid: playerid}, data, success, error); 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -