0

This is the scenario (check this Stackblitz):

  • I have two modules: AppModule and OtherModule.
  • In AppComponent (from AppModule), I create two dynamic components, using FirstComponent and SecondComponent.
  • In the FirstComponent template I insert HelloComponent, that belongs to the same module (AppModule), and it works fine.
  • The problem comes in the SecondComponent, where I insert ThirdComponent, that belongs to OtherModule. I receive the error: 'third' is not a known element.
  • OtherModule is imported in AppModule.
  • If I remove <third></third> from second.component.html the app will run, but I need to insert ThirdComponent inside SecondComponent, and SecondComponent is dynamic.

So, how can I use inside a dynamic component a component from a different module?

Angular CLI: 12.0.1

1 Answer 1

2

You have to export the components that throw errors. What I mean is that you need to include the third component in the exports array in OtherModule. It should work.

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.