*ngFor change class of individual elements


#1

I want to be able to create a list of items using *ngFor as follows…

Text - Image
Image-Text
Text - Image
Image-Text

  <ion-grid>
    <ion-row *ngFor="let item of items">
      <ion-col col-6 ">
        <ion-card ">
          <ion-card-content>{{item.name}}
          </ion-card-content>
        </ion-card>
      </ion-col>
      <ion-col col-6 >
        <ion-card>
          <img [src]="item.img"/>
        </ion-card>
      </ion-col>
    </ion-row>
  </ion-grid>

However, I am unsure how I could achieve this in a for loop.
Any suggestions? Thanks

UPDATE: Found answer here


#2

Another option is to use ngFor's odd and even.