I'm working on an angular 1.5 app that makes heavy use of ui-router.
We define our states like this:
$stateProvider
.state('jobs', {
url: '/jobs',
template: '<ut-jobs></ut-jobs>',
});
Notice that the template for this page is a simple angular directive rather than a template string (or templateUrl) with a separate controller. Our directive's controllers are defined inline, like this:
angular.directive('utJobs', () => {
return {
templateUrl: 'jobs.html',
controllerAs: 'jobs',
controller: [() => {
console.log('jobs directive loaded!');
}],
}
});
This lets us keep things nice and tidy, since our directive's controllers are close to the directive definition.
We would like to leverage ui-router's resolve feature to help simplify our resource fetching. However, since our state controllers aren't kept in $stateProvider.state definitions, I can't figure out for the life of me how to access the result of resolve (job in the above example.) Is there some kind of $resolve service that I could inject into the directive's controller to access the resolved resources? Am I missing something obvious? Or is ui-router not support this?