我有一个延迟加载的模块,在这个组件内默认为SuperUserComponent,我必须使用ngSwitchCase在4-5个子组件之间切换导航。因为我要在nativescript中使用它,所以我需要为整个路由模块使用一个单独的路由模块。
在我的主路由模块中,我有:
{
path: 'super-user',
loadChildren: './super-user/super-user.module#SuperUserModule',
pathMatch: 'full'
},在模块自己的子路由模块中,我有:
const routes: Routes = [
{
path: ':resource',
component: SuperUserComponent,
pathMatch: 'full'
}
];开关的切换如下所示:
<mat-button-toggle
[routerLink]="['/super-user', 'manage-users']"
value="manage-users"
>
Users
</mat-button-toggle>在后端,我每次加载主组件时都会监听该参数:
this.paramSubscription = this.route.paramMap.subscribe(params => {
const newValue = params.get('resource');
this.superUserMenu = newValue;
});如何配置子路由模块以在加载时匹配该参数?
发布于 2019-03-20 22:46:10
做了一些研究,你所需要做的就是改变你的主路由模块
{
path: 'super-user',
loadChildren: './super-user/super-user.module#SuperUserModule',
pathMatch: 'prefix'
}或者,如果您不需要pathMatch: 'prefix'行,则将其删除。我认为你只是强迫angular去寻找以“超级用户”结尾的路径,但他显然不能这样做。
https://stackoverflow.com/questions/55262968
复制相似问题