Reputation: 329
Here is my code
$stateProvider
.state('admin', {
abstract: true,
templateUrl: "views/common/content.html",
resolve: {
channel: function($stateParams){
return $stateParams.id
}
}
})
.state('admin.dash',{
url: "/dash",
templateUrl: "views/admin/admin_dash.html"
})
and i have many controllers for this admin_dash.html view using ng-controller. And in any of these controllers (child) i am not able to inject 'channel' which is the resolved dependency of the parent state, which should be inherited.
Upvotes: 1
Views: 99
Reputation: 959
The resolve injectables will not be available to any old ng-controller
, but only to the controller specified to the state.
E.g.
$stateProvider
.state('admin', {
abstract: true,
templateUrl: "views/common/content.html",
resolve: {
channel: function($stateParams){
return $stateParams.id
}
}
})
.state('admin.dash',{
url: "/dash",
templateUrl: "views/admin/admin_dash.html",
// Injectable here
controller: function(channel, $rootScope) {
console.log('Received channel from parent resolve:', channel);
// If need for ng-controller bound controllers...
$rootScope.channel = channel;
}
})
Upvotes: 1