作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
有没有办法在父路由的<router-outlet>
中显示子路由? ?
例如,假设我们有两条路线:
/users/12345
/users/12345/orders/12345
我需要第二个成为第一个的 child ,但我还需要完全替换 /users/12345
的内容内容为 /users/12345/orders/12345
反对拥有/users/12345/orders/12345
在/users/12345
子router-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/
我是一名优秀的程序员,十分优秀!