I have configured the resolve
parameter of several routes to return a promise in order to delay instantiation of the controller until the promise is resolved. Curre
The first example you have is the way to go, I think you could go a little bit "DRYer" like this:
.when('/article/:id', {
...
resolve: {
article: ['contentPromise', function (contentPromise) {
return contentPromise();
}]
}
})
Service:
.factory('contentPromise', ['Content', '$route', function (Content, $route) {
return function() {
return Content.get({ contentId: $route.current.params.id }).$promise;
};
}])