I'm following the Angular main page and I've extended $resource to add the update method like this:
angular.module('user', ['ngResource']).
factory('User', function($resource) {
var User= $resource('/user/:id', {
update: {
method: 'PUT'
}
});
User.prototype.update = function(cb) {
return User.update({ // this line throws the error
id: this.id
}, angular.extend({}, this, {
_id: undefined
}), cb);
};
However running:
$scope.user.update()
throws a TypeError: Object function h(a){v(a||{},this)} has no method 'update'
I can't see what I'm missing right now, any help appreciated
I found the issue in fact I need to pass an empty object for the paramDefaults arg:
var User= $resource('/user/:id', {}, {
update: {
method: 'PUT'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With