Curtis Hennessy
Curtis Hennessy

Reputation: 25

Ionic pass *ng-for information into query params

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

Answers (1)

joka00
joka00

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

Related Questions