How to disconnect the linked object?

I am using AngularJS and FireBase in my application. I attached the object to synchronization with FireBase:

$scope.winnerPromise = angularFire(travelBidsFirebaseRef + "/user/" + $scope.auction.winnerUserId, $scope, 'winner', {}); 

Now I want to disable $ scope.winner, that is, I want it to remain safe in the FireBase database, but I do not want my winner variable to be synchronized with it anymore. How should I do it? I saw disassociate () finence in angularfire.js, but I don't see how I can use it. Any ideas?

+4
source share
2 answers

The disassociate function is passed to you when the promise is resolved. I would 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. }); 

Hope this helps!

+2
source

I use angularfire and for me it worked with the $destroy method.

https://github.com/firebase/angularfire/blob/master/docs/reference.md#destroy-1

0
source

Source: https://habr.com/ru/post/1496123/


All Articles