I am using Angular 4+. Please note: first and last needs to be based on the class instance, not the element. So a let first = first in the ngFor will not work. I currently imported jQuery to handle this but would like to see if there is a way not to use jQ.
In the component ts file:
items: any = [{number: 0, text: 'blah blah'},{number: 0, text: 'blah blah'},{number: 1, text: 'blah blah'},{number: 1, text: 'blah blah'},{number: 1, text: 'blah blah'}, etc...
In the HTML file:
<ion-row *ngFor="let item of items [ngClass]="'item-class-' + item.number">
<ion-col>{{item.text}}</ion-col>
</ion-row>
Now what I want to do is grab the first instance of a class and last - once I have it I want to style it or add a class to the row. For example in jQuery I would have done this:
$( 'ion-row.item-class-0' ).first().css( 'background-color', 'red' );
$( 'ion-row.item-class-1' ).first().css( 'background-color', 'red' );