首页 > 解决方案 > Angular6:延迟加载时的引导模块组件

问题描述

解释

我有一个辅助模块,它为内部模块提供共享逻辑/视图(为简单起见,在此示例中添加了页脚)。

结构如下:

app.routing中,模块app延迟加载到container模块,如下所示:

  {
    path: 'inner1',
    loadChildren: 'app/container/container.module#ContainerModule'
  },
  {
    path: 'inner2',
    loadChildren: 'app/container/container.module#ContainerModule'
  },

虽然container.routing.ts选择正确的组件:

  {
    path: 'inner1',
    component: Inner1Component,
  },
  {
    path: 'inner2',
    component: Inner2Component,
  }

container.module引导它自己的组件:

  bootstrap: [
    ContainerComponent
  ]

哪里container.component.html有一个router-outlet和一个页脚:

<router-outlet></router-outlet>
<footer>
   // Stuff here
</footer>

现在 的问题

当路线是inner1,container.component永远不会真正激活并且页脚永远不会显示。似乎router-outletapp.component.html正在直接显示 的内容inner1.component.html

客观的

app.modulerouter 在其出口中显示container.component内容,路由器在其出口中container.module显示。inner1.componentcontainer.component

如何做到这一点?

标签: angular

解决方案


推荐阅读