In my run
function, I am handling the $routeChangeSuccess
event. My goal is to use $http
to load some data and then change the $template
. The issue here is that $http
works asynchronously. I have attempted to return a promise inside the event, but it has not been successful. Should I resort to using jQuery directly instead of $http
to load my resource?
app.run(["$rootScope", "$http", "$location", "$q", "localize", function($rootScope, $http, $location, $q) {
$rootScope.$on("$routeChangeSuccess", function(event, current, previous) {
var promise = $q.defer();
//load something and resolve promise when everything is ready
return promise;
});
}
]);