2

I am going to add a dynamic component to the Angular template. Usually, it is done by creating a dynamic component via the existing ViewContainerRef in the template. But what about the situation where there is no ability to define manually? Is there some ability to put the view container to DOM programmatically? Like it can be done for other types of DOM Nodes via Renderer2's createElement method.

I tried to add ng-container via Renderer2, but it behaves as DOM element, not as view container ref.

Sergey E.
  • 21
  • 1
  • A completely unplanned dynamic component is (so far as I know) not possible. But if you tell us our problem we can find a reason eventually. – Flo Feb 18 '23 at 11:28
  • You’d need to attach your component to something in the end I guess? Maybe have a look at angular material cdk - you could use a portal if that suits your requirements. – MikeOne Feb 18 '23 at 12:49

0 Answers0