Javascript Firebase:angularjs范围内的$save for$asArray()的3路绑定

Javascript Firebase:angularjs范围内的$save for$asArray()的3路绑定,javascript,angularjs,firebase,angularfire,Javascript,Angularjs,Firebase,Angularfire,我有一个removeFunction,可以从firebase拼接我的原始模型,但不幸的是,它不能与firebase同步,我不知道如何做到这一点 <a href="#{{product.title}}" ng-click="removeNode(product,brandBlock.products)">Remove</a> $scope.removeNode=function(item,parent){ parent.splice(parent.

我有一个removeFunction,可以从firebase拼接我的原始模型,但不幸的是,它不能与firebase同步,我不知道如何做到这一点

<a href="#{{product.title}}" ng-click="removeNode(product,brandBlock.products)">Remove</a>

$scope.removeNode=function(item,parent){
            parent.splice(parent.indexOf(item), 1);


            // Add a function here that will do something simillar with:
            // ng-blur="myCards.$save(card)" from the product title


        }; 

$scope.removeNode=函数(项,父项){
母接头(母接头索引(项目),1);
//在此处添加一个函数,该函数将执行类似的操作:
//产品标题中的ng blur=“myCards.$save(card)”
}; 
我希望能够将修改后的阵列保存回firebase,因为此函数在视图中执行此操作:

<input type="text" ng-model="product.title" ng-blur="myCards.$save(card)">

我知道我可以在angular blur指令中嵌套两个函数,如下所示:

<a ng-click="removeNode(product,brandBlock.products); myCards.$save(card)">Remove</a>

如果您设法将removeFunction添加到同步,并且块用完,则可以在此处添加一个新的firebase节点,您可以在appRef变量中替换该节点


AngularFire文档非常明确:“列表中的项目不应使用push()或splice()等数组方法直接修改”()。为什么你不能简单地使用
$remove
?如果我正确理解你的小提琴,你就有嵌套数组了。不知何故,
$remove
在子阵列上不可用。我不知道如何解决这个问题,但您可能希望更新问题,使嵌套数组(和ng重复)的事实更加明确。@FrankvanPuffelen感谢您研究我的问题。问题是,如果我确实删除了一些带有拼接的项目,然后添加了一个带有ng submit=myCards的表单。$save(card)“它将在删除项目后保存到firebase……或者即使我执行了ng click=“removeNode(product,brandBlock.products)”;myCards.$save(card)”所以拼接工作正常…我想。Frank是正确的。不要使用splice()和嵌套数组。两者都会给您带来麻烦(像这样)。使用$remove()。若你们想要一个同步的子对象数组,那个就创建它。@Kato-我似乎找不到任何关于嵌套数组和ng repeat的内容。你们建议如何删除它?我刚刚意识到拼接会导致firebase出现问题,它们会变得不同步…:(