Angular5在延迟加载模块中使用外部组件
我有一个惰性加载的 LazyModule,以及另一个 ModuleA。我需要在 LazyModule 中使用组件 Module-A-Component 。我如何访问这个外部组件?我在所有应用程序中使用 Module-A-Component。
如果我在 LazyModule 的声明数组中添加 Module-A-Component 会出现错误:
Module-A-Component 是 2 个模块声明的一部分...
如果我仅在 LazyModule 中移动 Module-A-Component,我就无法在应用程序的其他部分使用它。
如何在延迟加载模块和其他模块中使用外部组件?
I has LazyModule which I load lazy, and another one ModuleA. I need to use component Module-A-Component inside LazyModule. How can I access this external component? I use Module-A-Component around all application.
If I add Module-A-Component in daclaration array of LazyModule got the error:
Module-A-Component is part of the declarations of 2 modules...
If I move Module-A-Component only in LazyModule I can't use it in other parts of application.
How can I use the external component in lazy loaded module and other modules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于没有代码,所以我将给出理论上的答案。您需要创建一个
共享模块
。在其中创建Module-A-Component
并相应命名。然后在MOdule A
、MOdule-B
等中重用它。这也将确保不存在循环依赖。
Since there is no code, so I am gonna give a theoretical answer. You need to create a
shared-module
. CreateModule-A-Component
inside it and name it accordingly. Then reuse it inMOdule A
,MOdule-B
and so on.This will also make sure that there are no circular dependecy.