Ionic 3 gets the index of the clicked item
I need to get the index of the clicked item in the ion list, so I can access the position in the array.
The html code I use is:
<ion-list>
<ion-item *ngFor="let poi of poiList" (click)="openPage(poi, $index)">
<h2> {{ poi.name }} </h2>
</ion-item>
</ion-list>
Inside the function, openPage
I printed the index in the console, but it shows up as "undefined". I couldn't find any other way to get the index correctly.
+3
source to share