第一个示例有效(但写得不好)。
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)。
但是,第二个示例在Chrome / Firefox中给了我Error: Cannot match any routes. URL Segment: 'foo-processing/another-list/1/details'
。
我在那儿丢失了东西吗?还是那个错误?
答案 0 :(得分:0)
应该是:
{
path: 'another-list',
component: FooAnotherListComponent,
children: [{
path: ':id/details',
component: FooAnotherListDetailsComponent,
outlet: 'details-view',
}