<ion-col size="6" *ngFor="let mylocation of currentLocation; let i=index">
<img src={{mylocation.img}} />
<ion-item lines="none">
<p style="margin-inline-start: unset; font-weight: bold;font-size: 12px;">{{{{mylocation.name}}</p>
<ion-icon *ngIf="!joinRequest" (click)="sendRequest(i)" slot="end" name="person-add"></ion-icon>
<ion-icon slot="end" *ngIf="joinRequest" name="checkmark-circle"></ion-icon>
</ion-item>
</ion-col>
guys anyone please answer
have a look this link i hope its work for you
If you use the same Variable in the Loop you change all icons of course. What i normally would do is to add a variable to every List (currentLocation
in your case) Item. Then use this variable and change this on click.
Thanks for your reply and ans guys, I found solution for this
<ion-col size=â6â *ngFor=âlet mylocation of currentLocation; let i=indexâ (click)=âgoToHome(i)â>
{{mylocation.name}}
<ion-icon slot=âendâ [ngClass]=âmylocation.isSelect?âjoin_requestâ:âperson-addââ [name]=âmylocation.isSelect?âcheckmark-circleâ:âperson-addââ>
goToHome(index: number) {
for (let i = 0; i < this.currentLocation.length; i++) {
if (index == i) {
this.currentLocation[i].isSelect = true;
this.joinRequest = this.currentLocation[i].value;
this.router.navigate([â/tabs/tab2â])
} else {
this.currentLocation[i].isSelect = false;
}
}
}