我使用 Angularfire 创建了待办事项列表。但是我在更新项目时遇到问题。我试试这段代码
var obj = $firebaseObject(ref);
obj.name = $scope.todo.title ;
obj.$save()
.then(function(ref) {
ref.key() === obj.$id; // true
}, function(error) {
console.log("Error:", error);
});
我怎样才能只更新选定的项目。
最佳答案
这个怎么样?
var obj = $firebaseObject(ref);
obj.$loaded().then(function () {
obj.name = $scope.todo.title;
obj.$save()
.then(function (ref) {
ref.key() === obj.$id; // true
}, function (error) {
console.log("Error:", error);
});
});
您正在尝试在加载之前保存它。
关于javascript - 更新 TodoList 上的项目 Angularfire,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36252066/