单个模块中的角度组模块引用

时间:2019-06-16 15:17:00

标签: angular reference angular-module

我的应用程序具有许多用户在决定注册之前可以参考的模块。我想让他们与其他人分开。

然后将延迟加载这些“ PreRegistration”模块。 目录预注册具有一个初始页面模块(最终还有其他模块),这些模块均由pre-reg.module.ts引用:

enter image description here

pre-reg模块是所有PreRegistration模块的集合(在这种情况下,只有1个):

enter image description here

在这种简单情况下,我想将其显示在app.component.html中,以便导入AppModule:

enter image description here

但是在app.component.html中,无法识别启动页面选择器。 SplashPageComponent没有功能,只有一个虚拟html。

enter image description here

但选择器正确。这是app.component.html抱怨缺少参考吗?

enter image description here

我的“可爱”组织似乎是在浪费时间。 有什么想法为什么不被引用? 提前致谢。 :-)瑜伽士

2 个答案:

答案 0 :(得分:1)

我假设您忘记了在SplashPageModule中导出SpashPageComponent。

splash-page.module.ts ...

@NgModule({
declarations: [SpashScreenComponent, ....],
exports: [SpashScreenComponent]
})

答案 1 :(得分:1)

这里缺少几件事:

  1. 您需要声明模块中的组件,以便将角度 知道了
  2. 要在声明的模块外部中使用组件,您需要将其导出到模块中,以便可以在其他地方使用。

splash-page.module.ts

@NgModule({
   declarations: [SpashScreenComponent, ....],
   exports: [SpashScreenComponent]
})