angularjs - angular $resource `user.$update()` is not found -
angularjs - angular $resource `user.$update()` is not found -
i have click handler changes active flag true. user.$update() doing post not put.
what proper (angular) way update user object using $resource?
$scope.setactive = function(user) { user.get({ id: user._id }, function(user){ user.active = true; user.$update(); }); }; my express route should watching put:
router.put('/:id', auth.isauthenticated(), controller.update);
you can alter method of $update function put when you're creating service/factory:
angular.module('app.services').factory('user', function($resource) { homecoming $resource('/api/users/:id', { id: '@_id' }, { update: { method: 'put' // method issues set request } }); }); check link more info.
angularjs angular-resource
Comments
Post a Comment