Angular $resource update method not found

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'
    }

}

You are using the minified angularjs version, so you have to use to array notation. Just inject the required services in an array followed by the function:

angular.module('user', ['ngResource']).
factory('User', ['$resource', function($resource) {
  var User= $resource('/user/:id', {
    update: {
      method: 'PUT'
    }
  });

  User.prototype.update = function(cb) {
    return User.update({
      id: this.id
    }, angular.extend({}, this, {
      _id: undefined
    }), cb);
  });
}]);

Note: the same applies for your directives, controllers, ...

In resource instances, the method name is prefixed with $.

$scope.user.$update({}, cb);