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?

Upvotes: 0

Views: 73

Answers (1)

Shashank Vivek
Shashank Vivek

Reputation: 17494

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.

Upvotes: 1

Related Questions