Lloyd Banks
Lloyd Banks

Reputation: 36659

Using $loaded vs Waiting for Promise on $bindTo in AngularFire / Firebase

I am currently using

syncObject.$bindTo($scope, 'data').then(function(){
    $scope.dataLoaded = true;
});

to check when data sync with Firebase is completed.

After reading the documentation, I see that

syncObject.$loaded(  
  $scope.dataLoaded = true;
);

does something similar.

Is there a difference between the two methods?

Upvotes: 0

Views: 737

Answers (2)

Lloyd Banks
Lloyd Banks

Reputation: 36659

The promise on $bindTo does indeed call $loaded internally. If you were using $bindTo, you could use the promise callback to achieve what $loaded does

Upvotes: 2

Cory Silva
Cory Silva

Reputation: 2811

Your first code block does "three way binding" and the second does not. Also per the documentation, AngularFire provides a shortcut method for things passed into $FirebaseObject.$loaded()

Upvotes: 1

Related Questions