lundi 13 avril 2015

Prevent controller from running before HTTP request is fulfilled?


Vote count:

0





$rootScope.$on("$stateChangeStart", function(event, toState, toParams, fromState, fromParams){
if ($rootScope.carNameMap) {
_import.stateEvent.changeTitle(toState, toParams, event);
} else {
_import.getCompanies.init().then(function(res){ //<-- promise
_import.stateEvent.changeTitle(toState, toParams, event);
});
}
});


As you can see, in my $stateChangeStart I check if carNameMap was already created, if not I run a service that sends HTTP request, and returns a promise.


But when I have a remote db, my controller runs before http request ends.


How can I prevent controller from running before HTTP request is fulfilled?



asked 1 min ago







Prevent controller from running before HTTP request is fulfilled?

Aucun commentaire:

Enregistrer un commentaire