0

How do I create a component from a variable name in Angular similar to what can be achieved in Vue using Dynamic Components:

<component :is="myTemplate.type"></component>
tony19
  • 125,647
  • 18
  • 229
  • 307
Kuba Szymanowski
  • 1,307
  • 11
  • 25

1 Answers1

1

Before Ivy: You should use the ComponentFactoryResolver. You can check out a good example of it here: link

With Angular Ivy
You can use the renderComponent function. You can check out my blog about Ivy and dynamic component rendering here: link

Eliran Eliassy
  • 1,590
  • 12
  • 25