I have question regarding AngularJS. I want to make ng-repeat for some array. But data for this array i get from firebase in controller. Problem is, when page is rendering, iam still waiting for data from async function which get data from firebase.
What is the best way to control it? I tried to used promisses, but something was wrong and page was rendered before i got data from firebase.
i.e
$scope.games = [];
function getOnce(){
var defer = $q.defer();
ref.once("value", function(data) {
defer.resolve();
$scope.games.push('test');
});
return defer.promise;
}
$scope.getdata = getOnce().then(function(data){
console.log('success');
console.log(data);
});
And i call '$scope.getdata' function on init 'data-ng-init="getdata()"' What i wrong here? Or how can i get my goal?
ng-initjust to trigger controller function, call it in controller. Alsoresolveisn't passing any data down the promise chaingetdataproperty is not a function, its a promise object.