'Angular5 use external component in Lazy loaded Module

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?



Solution 1:[1]

Since there is no code, so I am gonna give a theoretical answer. You need to create a shared-module. Create Module-A-Component inside it and name it accordingly. Then reuse it in MOdule A , MOdule-B and so on.

This will also make sure that there are no circular dependecy.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shashank Vivek