【发布时间】:2017-07-19 18:58:25
【问题描述】:
我有一个 Angular 4 应用程序和我的 private.component.html 类似这样的东西:
<app-breadcrumb></app-breadcrumb>
<router-outlet></router-outlet>
还有我的路由:
const privateRoutes: Routes = [
{
path: '',
component: PrivateComponent,
children: [
{
path: 'dashboard',
component: DashboardComponent
},
{
path: 'settings',
component: SettingsComponent
},
{
path: 'companies',
component: CompaniesComponent,
children: [
{
path: 'add',
component: FormCompanyComponent
},
{
path: ':id',
component: CompanyComponent
}
]
}
]
}
];
第一层的所有组件都在PrivateComponent的router-outlet中呈现。但是我想要(如果可能的话)所有其他子级(并且我可以有多个级别),例如 /companies/add 或 /companies/20 仍然呈现在我的私有模板的同一 router-outlet 中。当然,我的实际代码希望我在 companies.component.html 中有插座。
这对于实现我的 breadcrumb 组件和编写 “Home > Companies > Apple Inc.” 非常重要。
可以创建一些这样的结构吗?
【问题讨论】: