I have defined my UI-Router states like this:
$stateProvider.state('contact', {
url: '/contactDemo',
views: {
'main': {
controller: 'contactMainController',
templateUrl: 'templates/contact.tpl.html'
}
}
}).state('contact.details', {
abstract: true,
controller: 'contactDetailsController',
templateUrl: 'templates/contact.details.tpl.html'
}).state('contact.details.add', {
url: '/add'
}).state('contact.details.filter', {
url: '/filter/{filterId}'
}).state('contact.details.filter.record', {
url: '/record/{recordId}',
resolve: {
record: ['$stateParams', 'Restangular', function($stateParams, Restangular) {
return Restangular.one('records', $stateParams.recordId).get();
}]
}
}).state('contact.details.filter.record.edit', {
url: '/edit'
});
Now I would like to inject my resolved record
into contactDetailsController
. If I do so, I get an Unknown provider
error. I can't move the resolve
into the abstract state, because from there I can't access the id inside $stateParams
.
If I move the controller
property down into the child state, my controller is never invoked.
Does anybody know how I can get the resolved property injected into the controller of an abstract parent state?