我正在关注这个角度流星教程http://angular-meteor.com/tutorials/angular1/bind-one-object
我不确定我的错误,但这是代码:
angular.module('socially').controller('PartyDetailsCtrl', function($scope, $stateParams, $meteor){
$scope.party = $meteor.object(Parties, $stateParams.partyId, false);
$scope.save = function() {
$scope.party.save().then(function(numberOfDocs){
console.log('save success doc affected ', numberOfDocs);
}, function(error){
console.log('save error', error);
});
};
$scope.reset = function() {
$scope.party.reset();
};
});
这是html:
Here you will see the details of party:
<input type="text" ng-model="party.name">
<input type="text" ng-model="party.description">
<button ng-click="save()">Save</button>
<button ng-click="reset()">Reset form</button>
<button ui-sref="parties">Cancel</button>
保存按钮正在正常保存对象,但重置动作不执行任何操作,没有错误或其他任何操作。
答案 0 :(得分:1)
$scope.party.reset();
不会清除表单,而只是将对象的当前值重置为存储在数据库中的值。例如,如果修改Parties
文档的属性并调用reset函数,则Meteor对象的客户端版本将重置为服务器版本。
详细了解$meteor.object。