第一个例子有效(但写得不好(。
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-处理/另一个列表/1/细节(。
然而,第二个例子给了我Chrome/FFirefox中的Error: Cannot match any routes. URL Segment: 'foo-processing/another-list/1/details'
。
我是遗漏了什么,还是那是个bug?
应该是:
{
path: 'another-list',
component: FooAnotherListComponent,
children: [{
path: ':id/details',
component: FooAnotherListDetailsComponent,
outlet: 'details-view',
}