angular - 在延迟加载的子模块中带有参数的角度路由?无法匹配每次抛出的任何路由
问题描述
我有一个延迟加载的模块,默认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;
});
加载时如何配置该子路由模块以匹配该参数?
解决方案
做了一些研究,你只需要改变你的主路由模块
{
path: 'super-user',
loadChildren: './super-user/super-user.module#SuperUserModule',
pathMatch: 'prefix'
}
pathMatch: 'prefix'
或者如果您不需要,只需删除该行。我认为您只是强迫 Angular 找到以“超级用户”结尾的路线,但他显然不能这样做。
推荐阅读
- mongodb - ReactiveMongo 带计数的分页
- windows - 如何在 Windows 10 上禁用 Internet Explorer Hsts
- postgresql - 存储线串时 PostGIS 纬度不正确
- javascript - javascript for 循环百分比计算每 12 个月
- python - 带有 AWS cognito 的无服务器框架生成 CORS 错误
- asp.net-mvc - “参数值缺失或无效。请为所有参数输入有效数据”。Telerik 报告 Rest Web API (.tdmx)
- sql - 存储基于时间的数据并识别差距
- email - A/B 测试电子邮件 - 添加另一个 utm- 变量
- botframework - Cortana Skill - 截取客户端桌面的屏幕截图
- javascript - 如何在给定的对象结构中使用 Ramda 执行嵌套更新?