You can change your Project factory a little bit:
updated after comment
angular.module('mongolab', ['ngResource']).
factory('Project', function($resource) {
var ProjectApi = $resource('https://api.mongolab.com/api/1/databases' +
'/villes/collections/universities/:id',
{apiKey: '7pcSaEmpVzZ90V6CVggeHa6Ys71uaZOA'}, {
update: {method: 'PUT'}
}
);
var Project = function(data) {
angular.extend(this, data);
};
Project.query = ProjectApi.query;
Project.get = ProjectApi.get;
Project.prototype.update = function(cb) {
return ProjectApi.update({id: this._id.$oid},
angular.extend(this, {_id: undefined}), cb);
};
Project.prototype.destroy = function(cb) {
return ProjectApi.remove({id: this._id.$oid}, cb);
};
return Project;
});
In EditCtrl
you make a strange thing:
function EditCtrl($scope, $location, $routeParams, Project) {
var self = this;
// Project is already defined in arguments and it is a service
var Project = Project.instance();
}
Calling Project.instance()
will return you plain resource object that doesn't have any update() method! Look at your code in Project factory.
Also change code in EditCtrl:
function EditCtrl($scope, $location, $routeParams, Project) {
var self = this;
Project.get({id: $routeParams.projetId}, function(projet) {
self.original = projet;
$scope.projet = new Project(self.original);
});
$scope.save = function() {
$scope.projet.update(function() {
$location.path('/list');
});
};
}
And finally you will have it working.
See plunker