如果我在路线上指定三名警卫,似乎所有警卫都会立即进行评估.
{path: '', component: OptionsComponent, canActivate: [ GuardOne, GuardTwo, GuardThree]}
我遇到的问题是我不希望GuardTwo在GuardOne完成之前运行.有没有办法实现这个目标?
我知道当canActivate函数返回一个简单的时boolean,角度路径保护以指定的顺序执行,但是,如果守卫返回类型Observable<boolean>或Promise<boolean>?
路线示例:
{
path: 'confirm',
canActivate: [AuthGuard, SessionExpiredAuthGuard, CheckoutAuthGuard],
component: CheckoutReviewOrderComponent
},
Run Code Online (Sandbox Code Playgroud)
SessionExpiredAuthGuard和CheckoutAuthGuard都返回类型Observable<boolean>.我不希望在SessionExpiredAuthGuard完成从异步http请求中检索数据之前执行CheckoutAuthGuard.
有没有办法强制这些异步防护按顺序执行?