Angular2在另一名后卫解决后运行Guard

Hos*_*adi 11 javascript angular2-routing angular

在我的项目中,我有两名警卫.AuthGuard和PermissionGuard.我需要首先运行AuthGuard,当它解决时,如果是true,则权限保护开始,但现在这些守卫正在并行运行,而且权限保护不能正常运行.我用于此问题的方式是我在Permission guard中调用了AuthGuard CanActivate方法,但我认为有一种更好的方法可以做到这一点.

zma*_*anc 1

我见过的最好的方法是在子路由上公开路由器防护。这是一个工作示例

{
  path:'', canActivate:[AuthorizationService1], 
    children: [
      {
        path:'', canActivate:[AuthorizationService2],component: HomeComponent
      }
    ]
}
Run Code Online (Sandbox Code Playgroud)