Reputation: 6679
Is there a way to globally resolve a service for all the routes in AngularJs?
Let's say I need to get configuration from a Web Service for all the routes. Can we do something like the following pseudo-code?
$routeProvider
.when('*', {
resolve: {
config: function(myConfigService) {
return MyConfigService.getConfigPromise();
}
}
})
Upvotes: 2
Views: 358
Reputation: 48
ui-router might do the job instead. You can read up the difference between ui-router and ngRoute here:
What is the difference between angular-route and angular-ui-router?
Upvotes: 1