在我的项目中,我有两个守卫。 AuthGuard 和 PermissionGuard。我需要首先运行 AuthGuard,当它解决时,如果 permissionGuard 为真,permissionGuard 开始但现在这个守卫并行运行并且 permissionGuard 不能正常工作。我用于此问题的方法是在 Permission guard 中调用 AuthGuard CanActivate 方法,但我认为有更好的方法来执行此操作。
最佳答案
我见过的最好的方法是在子路由上公开路由守卫。这是一个 working example .
{
path:'', canActivate:[AuthorizationService1],
children: [
{
path:'', canActivate:[AuthorizationService2],component: HomeComponent
}
]
}
关于javascript - 在另一个守卫解决后,Angular2 运行守卫,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41296998/