Per the example in the documentation, child states will inherit resolved dependencies from parent states. Furthermore, you can have promises for parent dependencies be resolved before children are instantiated by injecting keys into child states.
See example from documentation:
$stateProvider.state('parent', {
resolve:{
resA: function(){
return {'value': 'A'};
}
},
controller: function($scope, resA){
$scope.resA = resA.value;
}
})
.state('parent.child', {
resolve:{
resB: function(resA){
return {'value': resA.value + 'B'};
}
},
controller: function($scope, resA, resB){
$scope.resA2 = resA.value;
$scope.resB = resB.value;
}
However, how do you do this if the dependency is NAMED, not a function. For example, see bolded part:
$stateProvider.state('parent', {
resolve:{
resA: 'ServiceA'
}
},
controller: function($scope, ServiceA){
$scope.ServiceA = ServiceA.value;
}
})
.state('parent.child', {
resolve:{
ServiceB: ServiceB
}
},
controller: function($scope, ServiceA, ServiceB){
}
I can't figure out how to make ServiceB wait for ServiceA to first be instantiated before instantiating.
I tried putting 'ServiceA' as a dependency for ServiceB, but that doesn't work.
Thanks in advance for any help.