4
votes

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', {});

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?

2

2 Answers

2
votes

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.
});

Hope this helps!