Iterate children TemplateRefs from TemplateRef


Is it possible to iterate TemplateRefs from TemplateRef?

<my-component [template]="template"></my-component>
<ng-template #template>
    <ng-template *ngFor="let field of fields">
        bla bla bla

I want to do something like this.

@Input() template: TemplateRef<any>

and into the template something like this

<div *ngFor="let x of template">
    <h1>Bla bla bla</h1>
    <div *ngTemplateOutlet="x"></div>

Source: Angular Questions

Categorized as angular, ng-template Tagged ,


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us