我有这样声明的路线:
const appRoutes: Routes = [
{
path: '',
component: AppComponent,
children: [
{
path: 'elenco-interventi',
component: InterventiComponent,
children: [
{
path:'nuovo-intervento',
component: NuovoInterventoComponent
}
]
},
]
}
]
在AppComponent
我只有<div>
一个<router-outlet>
内部,并且组件InterventiComponent
正确加载到 address /elenco-interventi
。NuovoInterventoComponent
然后我希望在 address 找到孩子/elenco-interventi/nuovo-intervento
,它必须完全替换父组件的内容。
如何<router-outlet>
正确使用 in 父级,以便我可以替换父页面的全部内容,如果我返回路由,还可以重新加载父页面并隐藏/不显示子组件内容?
例子:
<div>
<!--parent content-->
<router-outlet></router-outlet> ==> when routing to children, just show children content
and not children+parent content as I do now
</div>