我在我的应用程序中使用AngularJS和FireBase.我绑定了一个与FireBase同步的对象:
$scope.winnerPromise = angularFire(travelBidsFirebaseRef + "/user/" + $scope.auction.winnerUserId, $scope, 'winner', {});
现在我想解除$scope.winner的关联,这意味着我希望它在FireBase DB中保持安全,但我不希望我的范围变量’winner’再次与它同步.我怎么做?我在angularfire.js中看到了disassociate()finction,但我看不出如何使用它.有任何想法吗?
最佳答案 解析后,解除关联函数将传递给您.我用它如下:
var ref = travelBidsFirebaseRef.child("user/" + $scope.auction.winnerUserId);
var promise = angularFire(ref, $scope, "winner", {});
promise.then(function(disassociate) {
// Do some work...
disassociate(); // Don't synchronize $scope.winner anymore.
});
希望这可以帮助!