I have 2 states in coffeescript...
stateProvider.state 'test',
...
resolve:
user: (LongRunning)->
LongRunning.authenticate().then ->
console.log("We are authenticated!")
stateProvider.state 'test.child',
...
resolve:
other: (AfterAuth)->
AfterAuth.soSomethingWithAuth().then ->
console.log("We are done!")
Of course this doesn't work because the child resolve is kicked off before the parent's auth method has been resolved. This means the second function won't be authenticated and cause the entire state to fail.
Now it doesn't need to necessarily be part of the State path but it needs to be fully completed by the time the resolve functions are called.
How would I make sure the function from parent is fully resolved before calling the method in child?
Bad (?) Solution
The one answer I have been able to come up with is to use the manual bootstrap process. However, this is tedious since I would need to rewire all my services. Is there anyway I can do it inside Angular?
Do you use AngularUI Router for Angular 2 or AngularJS? I think that is AngularJS on the fact that you use coffeescript and AngularUI Router. This is Angular tag not AngularJS.
Anyway in AngularUI Router one resolver can depends on another one. Something like that:
function firstStep($stateParams, resolveStatus) {
return $q.resolve();
}
resolve: {
firstStep: firstStep,
secondStep: ['firstStep', function (firstStep) {
...
}]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With