Ion-row within ion-list change background-color when tapped

Hi,

I have an ion-list with ion-rows generated thru ngFor. I want to change the color of the ion-row when tapped. How can i achieve it?

I have this sample code but it changes the background color of ALL the ion-row. I want to change only the tapped ion-row. Thanks for the help

HTML

<ion-list no-lines>
  <ion-row *ngFor="let i of myList; let j = index" (click)="changeBgColor(i)"  [ngStyle]="{ 'background-color': tapColor }">
    <some text and elements here>
  </ion-row>
</ion-list>

TS

tapColor: string;

changeBgColor(param) {
this.tapColor = “red”;
}

Hi guys,

Any ideas? Your help is very much appreciated

Already answered similar question

please give us in details