mardi 21 juillet 2020

Angular - Create HTML Elements and Angular Components dynamically

I am currently working on an Angular 10 project where I have to add native HTML-elements like div, table, p, h1 to the DOM (this could be achieved in Angular with the DomSanitizer) from the TypeScript class. But I also want to create an Angular component inside an created div.

Because creating just one component is easy with the ComponentFactoryResolver.

For example, this should be created from Typescript dynamically:

<div>
<my-component></my-component>
</div>

How can I achieve this? Kind regards, Steve




Aucun commentaire:

Enregistrer un commentaire