我想从我的firebase数据库中将状态字段从false更新为true

时间:2016-05-31 12:11:00

标签: angularjs firebase firebase-realtime-database

{
  "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数据库的图片:

http://i.stack.imgur.com/plTH6.jpg

0 个答案:

没有答案