gpt4 book ai didi

Angular 2 : Have Child Route Component Replace Parent in router-outlet

转载 作者:太空狗 更新时间:2023-10-29 16:53:04 25 4
gpt4 key购买 nike

有没有办法在父路由的<router-outlet>中显示子路由? ?

例如,假设我们有两条路线:

/users/12345

/users/12345/orders/12345

我需要第二个成为第一个的 child ,但我还需要完全替换 /users/12345 的内容内容为 /users/12345/orders/12345反对拥有/users/12345/orders/12345/users/12345router-outlet .

我以为我可以通过命名父级路由器导出并让两条路由都以它为目标来做到这一点,但是从我一直在做的研究(以及它造成的错误)来看,我觉得这些名字是为了当已经存在主路由器 socket 时的二次使用

最佳答案

我遇到了同样的问题。我就是这样修复它的:

const routes: Routes = [
{
path: '',
children: [
{
path: '',
component: ParentComponent,
},
{
path: 'child',
component: ChildComponent,
}
]
}
];

关于 Angular 2 : Have Child Route Component Replace Parent in router-outlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42841976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com