Pass parameter by (Click) on card


#1

Hello everybody,

I feel dummy, but I can not pass a parameter when clicking on a card.
Here is my html file where I want pass the id of my item to the function navigate :

<ion-content class="cards-bg">
  <ion-list>
    <ion-item *ngFor="let item of (items |async)?.slice().reverse()" text-wrap>
      <ion-card tappable (click)="navigate(item.id)" class="cards-bg">
        <img src="assets/imgs/chpt2017.jpeg"/>
        <ion-card-content>
            <ion-card-title>
                {{item.titre}}
            </ion-card-title>
            <p>
                {{item.titre2}}
            </p>
          </ion-card-content>
      </ion-card>
    </ion-item>
  </ion-list>
</ion-content>

Here my .ts file :

navigate(id: string){
    console.log('id : ' || id);
    this.navCtrl.push('ArticlePage',id);
  };

And in the log, id is blank …

I searched before to ask my question, but I do not understand what I’m doing wrong.

Thanks a lot.


#2

Use console.log('id : ’ , id)


#3

And down the road u may need to

this.navCtrl.push(‘ArticlePage’,{id:id})

So u can adress the data using navparams.get(‘id’)


#4

Thanks a lot Tommertom !!!