【发布时间】:2017-02-28 06:41:12
【问题描述】:
我不知道如何使用基于 id 的 Firebase 进行读取和更新。在这种情况下,我有一个待办事项列表,我想根据其 $id 找到第一项,然后将 comple 更改为 true。
todos
-Ke0JWl9xy5sZvT55hfE
Complete: false
Created_at: 1488228401479
Description: "123"
Priority: "high"
-Ke0Ms_LnsO-TSwQZLcZaddclose
-Ke0MuWCLkX29XWYyPBM
-Ke0MwKOrjpDm9rj6L28
-Ke0NCmpM3_dTPtY9jVb
JS
(function() {
function Todo($firebaseArray) {
var ref = firebase.database().ref().child("todos");
var todos = $firebaseArray(ref);
Todo.todos = todos;
Todo.updateToDo = function(todo){
console.log(todos)
console.log(todos[todo['$id']])
};
return Todo;
}
angular
.module('blocitoff')
.factory('Todo', ['$firebaseArray', Todo]);
})();
【问题讨论】:
标签: angularjs firebase firebase-realtime-database angularfire