阅读背景:

AngularJS $资源创建新对象而不是更新对象

来源:互联网 
// Set up the $resource
$scope.Users = $resource("https://localhost/users/:id");

// Retrieve the user who has id=1
$scope.user = $scope.Users.get({ id : 1 }); // returns existing user

// Results
{"created_at":"2013-03-03T06:32:30Z","id":1,"name":"testing","updated_at":"2013-03-03T06:32:30Z"}

// Change this user's name
$scope.user.name = "New name";

// Attempt to save the change 
$scope.user.$save();

// Results calls POST /users and not PUT /users/1
{"created_at":"2013-03-03T23:25:03Z","id":2,"name":"New name","updated_at":"2013-03-03T23:25:03Z"}
// Set up the $resource
$scope.Users = $resourc



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: