我有以下Angular Route配置
const appRoutes: Routes = [
{
path: '',
component: DirectoryComponent
},
{
path: 'manage/:type/:id',
component: ManageComponent,
outlet: 'manage',
children: [
{
path: '',
component: PreviewComponent,
pathMatch: 'full'
},
{
path: 'add/:elementType',
component: EditComponent,
}
]
}
];
ManageComponent
是一个沙盒组件,将在其中渲染PreviewComponent
和。EditComponent
用户用例将用户重定向到http://localhost:4200/#/(manage:manage/bar/12762)
与预览组件匹配的用户。这里一切正常。
从PreviewComponent
和当用户点击一个按钮时,我想做一个相对导航到EditComponent
拥有,当导航完成时,http://localhost:4200/#/(manage:manage/bar/12762/add/foo)
我试过了
this.router.navigate([{outlets: {manage: ['add', 'foo']}}],{relativeTo: this.route});
和
this.router.navigate([{outlets: {manage: ['add', 'foo']}}]);
但每次,用户都会被重定向到http://localhost:4200/#/add/foo
.