Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can change your Project factory a little bit:</p> <p><strong>updated after comment</strong></p> <pre><code>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; }); </code></pre> <p>In <code>EditCtrl</code> you make a strange thing: </p> <pre><code>function EditCtrl($scope, $location, $routeParams, Project) { var self = this; // Project is already defined in arguments and it is a service var Project = Project.instance(); } </code></pre> <p>Calling <code>Project.instance()</code> will return you plain resource object that doesn't have any update() method! Look at your code in Project factory.</p> <p>Also change code in EditCtrl:</p> <pre><code>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'); }); }; } </code></pre> <p>And finally you will have it working.</p> <p>See <a href="http://plnkr.co/edit/tOmMu81ApyfSHM1lniVz?p=preview" rel="nofollow">plunker</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload