javascript - Detect alteration of AngularFireCollection with AngularJS -


basically, i'm trying use $watch angularfirecollection. doesn't appear working way want to.

this have @ moment:

$scope.bits = angularfirecollection(new firebase(url).limit(75));  $scope.$watch('bits', function() {      console.log('new');  }); 

so, when load page logs "new" in console when data first loaded, , that's fine, when new data comes in, doesn't log anything. idea why happens?

$watch looks @ object references (it compares them using ===), since $scope.bits same array instance, though contents have changed, doesn't fire listener.

you can pass additional parameter $watch makes comparison of contents of objects:

$scope.$watch('bits', function() {}, true); 

i'd never heard of using bits.length @robertklep suggested, looks elegant , i'd upvote if posted answer.


Comments