使用angularJS在嵌套的firebase中创建子节点

时间:2016-03-05 20:40:32

标签: javascript angularjs firebase

我正在尝试为"标题创建一个子节点"在火基地。我无法参考火柱并创建一个名为“时间”的孩子。并在每次用户点击按钮时存储时间。Here is the screenshot of my firebase.

这是我的代码:

  .controller('ListCtrl', function($scope, $firebaseAuth,$ionicListDelegate, $firebaseObject, $ionicPopup, $interval, $firebase) {


 $scope.stopSpam = false;


$scope.list = function(){
var FB = new Firebase("https://my-project.firebaseio.com");
var fbAuth = $firebaseAuth(FB);
fbAuth = FB.getAuth();
if(fbAuth) {
     var syncObject = $firebaseObject(FB.child("users/" + fbAuth.uid));
    syncObject.$bindTo($scope, "data");
}
}  

 $scope.addItem = function()  {
$ionicPopup.prompt({
    title: 'Enter a task you want to add',
    inputType: 'text'
})
.then(function(result) {
    if(result !== "") {
        if($scope.data.hasOwnProperty("todos") !== true) {
            $scope.data.todos = [];
        }
        $scope.data.todos.push({title: result});
    } else {
        console.log("Action not completed");
    }
});
}

 $scope.doneItem = function(todo) {

  $scope.todo = todo;
  $scope.todo['stopSpam'] = true; 

 $interval(callAtInterval, 3000);

 function callAtInterval(){

    todo.stopSpam = false;  

 }
   };
});

0 个答案:

没有答案