【发布时间】:2018-06-11 14:39:00
【问题描述】:
假设我有一个名为 Parent 的模块:
const routes: Routes = [
{
path: '',
component: ParentComponent,
children: [
{
path: '/:id',
component: ChildComponent
}
]
}
]
@NgModule({
declarations: [
ParentComponent,
ChildComponent,
],
imports: [
RouterModule.forChild(routes),
],
})
export class ParentModule {
}
这个模块有一些子路由可以提供很好的路由体验,但它有一个问题:我不知道如何从另一个模块添加更多子路由。
假设我想添加一个模块ChildDetailsModule,它声明一个ChildDetailsComponent,并想将它绑定到/:id/details,然后我就卡住了。因为我不想让ParentModule 知道这个组件,因为它是由另一个模块提供的,所以我希望能够通过从我的AppModule 的导入模块中删除ChildDetailsModule 来拔掉它。
有可能实现吗?我在当前的 Angular 文档中没有找到方法,我肯定必须这样做,因为我需要一个内部路由器插座,同时我还需要能够使用其他模块为这个内部路由器插座提供额外的路由。
【问题讨论】:
标签: angular angular6 angular-router