Angular 6路由到延迟加载的嵌套模块

时间:2018-10-18 08:30:06

标签: javascript angular typescript

我最近开始使用Angular 6,虽然基本方案可以很好地工作,但要使更复杂的路由方案能够工作仍然很困难。

到目前为止,我已经将我的应用程序划分为两个主要模块(以后还会有更多):身份验证和核心。

在核心模块中,我有一个核心组件,其中包含导航,页眉和页脚组件,然后是标签。

从核心导航中,用户应该能够访问应用程序的主要部分,例如:

  1. UsersModule-UserListComponent,AddUserComponent,EditUserComponent等
  2. ProductsModule-ProductListComponent,AddProductComponent,EditProductComponent等。

由于这些不同的模块将由不同的用户使用,所以我希望使用延迟加载将它们加载到CoreComponent-router-outlet标记中。最终它将看起来像这样:

enter image description here

问题是我不确定如何设置路由,因为当我尝试加载UserModule或ProductModule中的任何组件时,它们只是替换屏幕内容,而不是加载到CoreComponent的标签中。 / p>

代码如下:

app.module.ts

enter image description here

core.module.ts

enter image description here

user.module.ts

enter image description here

有人可以帮助我吗?

0 个答案:

没有答案
相关问题