angular - 导航到子路线给了我:“错误:无法匹配任何路线”(Angular 6)
问题描述
第一个例子有效(但写得不好)。
const FooProcessingRoutes: Routes = [{
path: '',
pathMatch: 'full',
redirectTo: '/foo-processing/list',
}, {
path: 'list',
component: FooListComponent,
}, {
path: 'another-list',
component: FooAnotherListComponent,
}, {
path: 'another-list/:id/details',
component: FooAnotherListComponent,
children: [{
path: '',
component: FooAnotherListDetailsComponent,
outlet: 'details-view',
}]
}];
export { FooProcessingRoutes };
第二个例子应该有效(在我看来),我希望这样:
const FooProcessingRoutes: Routes = [{
path: '',
pathMatch: 'full',
redirectTo: '/foo-processing/list',
}, {
path: 'list',
component: FooListComponent,
}, {
path: 'another-list',
component: FooAnotherListComponent,
children: [{
path: ':id/details',
outlet: 'details-view',
component: FooAnotherListDetailsComponent,
}],
}];
export { FooProcessingRoutes };
我需要:id/details
成为 的孩子another-list
。这两个示例都链接到我浏览器中的相同路径(即http://localhost:4200/#/foo-processing/another-list/1/details)。
然而,第二个例子Error: Cannot match any routes. URL Segment: 'foo-processing/another-list/1/details'
在 Chrome/Firefox 中给了我。
我在那里遗漏了什么还是一个错误?
解决方案
它应该是:
{
path: 'another-list',
component: FooAnotherListComponent,
children: [{
path: ':id/details',
component: FooAnotherListDetailsComponent,
outlet: 'details-view',
}
推荐阅读
- javascript - Laravel - 如何包含外部 JS 文件(包含 Ajax )
- database-design - 重构事实表的维度
- android - 您如何使用 copyToRealmOrUpdate 作为列表?
- javascript - vue.js 中的动态表行跨度
- c# - 调试错误:“没有给出与所需形式参数相对应的参数”
- javascript - 将 onchange 事件侦听器附加到 textarea
- python - 蟒蛇最大。3 个值,平均值和绘图
- javascript - 带有html表的Javascript onClick函数包括FORM
- bash - 为什么我的 bash 脚本没有打印最后一行?
- java - Spring Data JPA 生成的一对一自引用查询方式的 SQL 发生了变化