2

I'm using this method

<ng-container
   *ngComponentOutlet="myComponent">
</ng-container>

to inject one component into another component, in my case a form into a sidebar. However from the injected component (the form) I cannot use pipes and shared components of the application. No component or pipe present in the shared.module is recognized within the injected component. How can I make shared components available in the component injected through ngComponentOutlet?

I did it, but: I did it using the component factory angular-comp-factory. But actually I have another question: My component is getting rendered but without its sub-components. How can I render its sub-components using the component factory?

cs.edoardo
  • 494
  • 3
  • 11
  • 1
    Would you mind providing some code snippets? A (non-) working example would be great! (e.g. via stackblitz) – Kenan Güler Mar 24 '20 at 12:33
  • Hi @KenanGüler, i did it using just the built-in component factory of Angular. But actually the question is another one. The sub-components of my dynamic component are not instantiated... – cs.edoardo Mar 24 '20 at 13:21
  • 1
    I see. Glad, you solved your problem! However, AFAIK the component selector a la `` or the [`router-outlet`](https://angular.io/guide/router#router-outlet) is being used in most cases, rather than `ngComponentOutlet` one. – Kenan Güler Mar 24 '20 at 14:10

1 Answers1

0

I managed. It was only a problem with the arrangement of the modules.

cs.edoardo
  • 494
  • 3
  • 11