I am pulling out one value from every object in Firebase, picUrl (the url of a picture) and storing that in a scope array variable, $scope.bricks. How do I make it so $scope.bricks updates everytime Firebase is updated with a new object, and therefore new picUrl? Thanks in advance!
angular.module('noorApp').controller('MainCtrl', function ($scope, $http, $firebase) {
var sync = $firebase(ref);
var firebaseObj = sync.$asObject();
$scope.bricks = [];
firebaseObj.$loaded().then(function(){
angular.forEach(firebaseObj.products, function(value, key){
$scope.bricks.push({src: value.picUrl});
});
});
});
EDIT:
I should have posted how I'm using $scope.bricks in the DOM.
<div class="masonry-brick" ng-repeat="brick in bricks">
<img ng-src="{{ brick.src }}">
</div>
The issue is that while firebaseObj is synced with Firebase, $loaded() is only running once.
Thanks.