0

How can I get first active image in ionic from restful service?

Explanation: I am trying to create Infinite Scrolling Photo in ionic and I need first image to have a class="first". Using let i = index how can I achieve this?

What I tried:

<div class="photobanner" *ngFor="let slideImage of items; let i = index">
      <img class="first" src='{{slideImage[i].img}}' />
      <img src='{{slideImage[i+1].img}}'>
  </div>
Fagbemi Ayodele
  • 321
  • 5
  • 15

1 Answers1

0

You can do that with css. You select the first img child of the div photobanner

.photobanner > img:first-child {
  //do what you want
}

Other solution, you can find here how to add condition in ngFor. stackoverflow.com/questions/42931735/apply-a-condition-using-ngfor-and-ngif-in-angular

Cyril Wallis-Davy
  • 292
  • 1
  • 5
  • 9