I have 2 states in coffeescript...
我在coffeescript中有2个州......
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.
当然这不起作用,因为在解析父级的auth方法之前启动了子解析。这意味着第二个函数将不会被验证并导致整个状态失败。
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.
现在它不一定是状态路径的一部分,但它需要在调用resolve函数时完全完成。
How would I make sure the function from parent is fully resolved before calling the method in child?
在调用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?
我能够提出的一个答案是使用手动引导程序。然而,这是乏味的,因为我需要重新连接我的所有服务。无论如何我可以在Angular中做到吗?
1 个解决方案
#1
5
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.
你是使用AngularUI Router for Angular 2还是AngularJS?我认为AngularJS就是你使用coffeescript和AngularUI Router的事实。这是Angular标签而不是AngularJS。
Anyway in AngularUI Router one resolver can depends on another one. Something like that:
无论如何在AngularUI路由器中,一个解析器可以依赖于另一个。像这样的东西:
function firstStep($stateParams, resolveStatus) {
return $q.resolve();
}
resolve: {
firstStep: firstStep,
secondStep: ['firstStep', function (firstStep) {
...
}]
}
#1
5
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.
你是使用AngularUI Router for Angular 2还是AngularJS?我认为AngularJS就是你使用coffeescript和AngularUI Router的事实。这是Angular标签而不是AngularJS。
Anyway in AngularUI Router one resolver can depends on another one. Something like that:
无论如何在AngularUI路由器中,一个解析器可以依赖于另一个。像这样的东西:
function firstStep($stateParams, resolveStatus) {
return $q.resolve();
}
resolve: {
firstStep: firstStep,
secondStep: ['firstStep', function (firstStep) {
...
}]
}