我在Angular4中遇到问题,其中多个用户将访问路径'',我希望我的路由根据访问权限将其重定向到正确的组件。
这些是我的路线,但只考虑第一个:
export const appRoutes: Routes = [
{
path: '',
pathMatch: 'full',
redirectTo: 'main',
},
{
path: 'main',
component: MainComponent,
canActivate: [AuthGuard],
children: [
{
path: '',
pathMatch: 'full',
redirectTo: '(primary:dashboard)',
data: {
permission: PERMISSION_DASHBOARD,
},
canActivate: [PermissionGuard],
},
{
path: '',
pathMatch: 'full',
redirectTo: '(primary:custory)',
data: {
permission: PERMISSION_CUSTODY_TRANSFER,
},
canActivate: [PermissionGuard],
},
{
path: 'dashboard',
outlet: 'primary',
component: DashComponent,
data: {
permission: PERMISSION_DASHBOARD,
},
canActivate: [PermissionGuard],
},
{
path: 'custory',
outlet: 'primary',
component: CustodyComponent,
data: {
permission: PERMISSION_CUSTODY_TRANSFER,
},
canActivate: [PermissionGuard],
}
]
},
];
在上面的例子中,只评估了路径main中的第一个子节点,但是,我需要对它们进行评估。