Binding bindTo()在AngularFire中如何工作?

Binding bindTo()在AngularFire中如何工作?,binding,angularfire,Binding,Angularfire,我正在尝试实现三向绑定,但遇到了一些问题 用户可以在系统中添加三种不同类型的注释(A、B、C),下面是我如何使用bindTo功能的,但是,当用户创建新注释时,当用户单击一种特定类型的注释时,它会更新所有新注释。i、 e,当用户单击A类型下的添加注释,然后单击B类型下的添加注释时,实际上会更改以前的所有新注释 $scope.addNote = function(noteType){ $scope.addANote = false; $scope.addBNote = fa

我正在尝试实现三向绑定,但遇到了一些问题

用户可以在系统中添加三种不同类型的注释(A、B、C),下面是我如何使用bindTo功能的,但是,当用户创建新注释时,当用户单击一种特定类型的注释时,它会更新所有新注释。i、 e,当用户单击A类型下的添加注释,然后单击B类型下的添加注释时,实际上会更改以前的所有新注释

    $scope.addNote = function(noteType){

    $scope.addANote = false;
    $scope.addBNote = false;
    $scope.addCNote = false;

    var title = "A New Note";
    var content = "Adding Note here";
    var type = "New Type";

    var firebaseObj = new Firebase("https://XXXX/Notes");

    firebaseObj.push({ 
        title: title, 
        content: content,
        type: noteType,  
        username: username,
    });

    switch(noteType) {
        case 'A':
            $scope.addANote = true;
            break;
        case 'B':
            $scope.addBNote = true;
            break;
        case 'C':
            $scope.addCNote = true;
            break;
    } 

    // Get the note Key after user submit a new note
    var noteKey; 
    firebaseObj.on("child_added", function(snapshot, prevChildKey){
        noteKey = snapshot.key();
    }); 

    var ref = new Firebase("https://XXXX/Notes/" + noteKey);
    var syncNoteObj = $firebaseObject(ref);

    syncNoteObj.$bindTo($scope,"note").then(function(){
        console.log("threeway bingding:" + $scope.notes);
   });    
}
以下是视图中的代码:

                       <div id="navbar" class="navbar-collapse collapse">
                        <ul class="nav navbar-nav">
                          <li class="dropdown">
                            <a href="#">A <span class="caret"></span></a>
                            <ul class="dropdown-menu">
                              <li>            
                                <a href="#" onclick="return false;" ng-click="addNote('A')">New Note</a>
                              </li>
                            </ul>
                          </li>

                          <li class="dropdown">
                            <a href="#">B <span class="caret"></span></a>
                            <ul class="dropdown-menu">
                              <li>            
                                <a href="#" onclick="return false;" ng-click="addNote('B')">New Note</a>
                              </li>
                            </ul>

                          <li class="dropdown">
                            <a href="#">C <span class="caret"></span></a>
                            <ul class="dropdown-menu">
                              <li>            
                                <a href="#" onclick="return false;" ng-click="addNote('C')">New Note</a>
                              </li>
                            </ul>

所以我想知道bindTo()函数中的两个参数是什么,我用错了吗

所以,我找到了答案!:) 我只需要用当前注释解除范围绑定,下面是使用unbind的解决方案

        syncNoteObj.$bindTo($scope,"note").then(function(unbind){
        console.log("threeway bingding:" + $scope.note);
        $scope.unbindFunction = unbind;
   });

    // Use a flag to track when to unbind the scope with database
    if($scope.unbindingFlag){
        $scope.unbindFunction();
    }
    else{
        $scope.unbindingFlag = true;
    }