Iago Favilla
Iago Favilla

Reputation: 21

How to Use ngFor for multiple components?

So, i'm trying to use ngFor for 10 different components.

Something like that:

<ion-slide class="page-slide" *ngFor="let item of slideArr">
 <ion-card class="page-slide-card">
  <ion-card-content> {{item.title}}
    <component of number x></component of number x>
  </ion-card-content>
 </ion-card>
</ion-slide>

There are 10 components. Each one for each ion-slide. Is there a way other than ngIf to make them load on screen?

Upvotes: 0

Views: 168

Answers (1)

Wytze
Wytze

Reputation: 1565

Are these different components? In that case NgSwitch might be useful.

https://angular.io/api/common/NgSwitch

Upvotes: 1

Related Questions