【发布时间】:2019-10-19 05:43:08
【问题描述】:
我想知道您是否使用 RoleGuard 来检查是否有人可以激活路径,并且您希望在子项目中使用不同的 RoleGuard 是可能的:
我已经尝试过了,但我无法使用不同的 RoleGuard 访问路径
{
path: 'admin',
canActivate: [AdminGuard],
children: [
{ path: '', redirectTo: 'test', pathMatch: 'full'},
{ path: 'test', component: MasterDataComponent},
{ path: 'test/subtest', component: ObjectsTypeComponent },
{ path: 'test/subtest/:operation', component: ObjectsTypeDetailComponent },
{ path: 'test/subtest/:operation/:id', component: ObjectsTypeDetailComponent },
{ path: 'test/money', component: DivisesComponent, canActivate: [OperatorGuard] }
}
所以,只有管理员可以进入此路径,但我想允许操作员进入路径 test/money。
感谢您的建议。
【问题讨论】:
-
然后更改 AdminGuard 的实现或为 Operator 添加另一个保护。
标签: angular typescript angular-routing angular-guards