如何撇清angularFire绑定的对象? [英] How to disassociate angularFire bound object?
本文介绍了如何撇清angularFire绑定的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用我的应用程序AngularJS和火力地堡。我绑定的对象是在同步的火力点:
I am using AngularJS and FireBase in my application. I bound an object to be in sync with FireBase:
$scope.winnerPromise = angularFire(travelBidsFirebaseRef + "/user/" + $scope.auction.winnerUserId, $scope, 'winner', {});
现在我想撇清$ scope.winner,这意味着我希望它在火力地堡DB保持安全的,但我不希望我的范围变量'赢家'用它了同步。我怎么做?我看到angularfire.js解除关联()finction但我不知道怎样才能使用它。任何想法?
Now I want to disassociate $scope.winner, meaning I want it to stay safe in the FireBase DB, but I don't want my scope variable 'winner' to be synchronized with it anymore. How do I do that? I saw disassociate() finction in angularfire.js but I don't see how I can use it. Any ideas?
推荐答案
解除关联函数传递给你当的承诺得到解决。我想如下方式使用它
The disassociate function is passed to you when the promise is resolved. I'd use it as follows:
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.
});
希望这有助于!
这篇关于如何撇清angularFire绑定的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文