2

I have a parent modules(app.module) & a child module(contacts.module). The child module is lazy loaded. The parent module utilizes a component from the child module but when I navigate to the child route I get the error:

'app-contacts-home' is not a known element:
1. If 'app-contacts-home' is an Angular component, then verify that it is part of this module.
2. If 'app-contacts-home' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to 

Obviously that component isn't part of the parent module since it's being lazy loaded. I tried adding app-contacts-home as an entryComponent in contacts.module but had no luck.

How can I use a lazy loaded component in my parent component?

1 Answer 1

4

No you can't use a component from a child lazy load module in a parent module.

What you should do in these situations is to make a 3rd module (SharedModule) that will have the component that is used in components from both modules. Then import that 3rd module in parent and child module, that 3rd module won't be lazy loaded.

The documentation in this page https://angular.io/guide/sharing-ngmodules have useful information about that.

Hope that this helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.