angularjs - put response in ngResource -


how can put response ng-resource?

following code:-

_userservice.$update({id : $scope.user.userid }, $scope.user, function(result){    if (result.status === "success") {      toastr.success(result.message);    }; }); 

following factory:-

angular.module('app')   .factory('userservice', function ($resource) {       return $resource('http://localhost/ojadmin/api/users/:id', null,     {         'update': { method:'put' , params: {id: '@id'}}     });   }); 

i able update user not getting response in result. getting proper response in chrome developer tool's network tab.

i getting following response in chrome developer tool's network tab , record edited successfully:-

{"status":"success","message":"saved successfully."} 

i getting error :- typeerror: (success || noop) not function

i tried log out console :-

console.log(_userservice.$update({id : $scope.user.userid }, $scope.user)); 

output promise object

then tried following code:-

_userservice.$update({id : $scope.user.userid }, $scope.user).then(function(result){  if (result.status === "success") {          toastr.success(result.message);        }; }); 

i getting same error typeerror: (success || noop) not function.

i tried .$promise.then(function(data) { no success

how can rid of error , proper response?


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -