Reputation: 25
I have an *ng-for loop, churning out ion-items, but I want those items to route to another page, but pass the index of that item, as a query parameter.
Here is my code:
<ion-item *ngFor="let item of items; index as i;"
[routerLink]="['/itempage']" [queryParams]="{id: 'i'}"
routerDirection="forward">
<ion-label>{{item.name}}</ion-label>
</ion-item>
I have no idea how to get the { q: 'i' } part to actually make i equal to the index, I keep getting errors and such.
Upvotes: 1
Views: 472
Reputation: 2537
You are not setting an index there but you are setting id
to 'i'
which is string.
Change it to this [queryParams]="{id: i}"
Upvotes: 3