Alexander Burakevych Alexander Burakevych - 1 year ago 112
AngularJS Question

How to disassociate angularFire bound object?

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, '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?

Answer Source

The disassociate function is passed to you when the promise is resolved. I'd use it as follows:

var ref = travelBidsFirebaseRef.child("user/" + $;
var promise = angularFire(ref, $scope, "winner", {});
promise.then(function(disassociate) {
  // Do some work...
  disassociate(); // Don't synchronize $scope.winner anymore.

Hope this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download