Iterate children TemplateRefs from TemplateRef

Published

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
    </div>
</ng-template>

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>
</div>

Source: Angular Questions

Published
Categorized as angular, ng-template Tagged ,

Answers

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
faq