{
"task" : {
"-KJ-PCQsvzADqpxnhkq7" : {
"description" : "Hello World",
"status" : true,
"title" : "Hello"
},
"-KJ-PCoALMUCMehs0UYF" : {
"description" : "kjkjj",
"status" : true,
"title" : "ghghg"
},
"-KJ-PCptX9r1KLIw75__" : {
"description" : "kjkjj",
"status" : "false",
"title" : "ghghg"
},
"-KJ-PCu-xleYzZrNiy6x" : {
"description" : "kjkjj",
"status" : "false",
"title" : "ghghg"
}
}
}
单击按钮我想将状态从false更改为true。
$scope.updateTask = function(task) {
var itemref = new Firebase("https://tasksbylima.firebaseio.com/task");
var taskref = itemref.orderByChild("status").equalTo(true);
taskref.on("value", function(snapshot) {
$scope.updateStatus = snapshot.val();
$scope.updateStatus.child("status").update({status: "false"});
console.log(snapshot.val());
});
}
以下是Firebase数据库的图片: