Siva Unique
Siva Unique

Reputation: 189

how to get id when we are click the button using angular and ionic?

I am using the below code and i am not getting id when i am clicking.

<button ion-item  (click)="goToDrivePage()" *ngFor="let eventNames of eventType.events">
          {{eventNames.id}}
       </button>

any body help me to get id in the function?

Upvotes: 1

Views: 2310

Answers (1)

Arun Kumaresh
Arun Kumaresh

Reputation: 6311

Pass the id value to the function

<div *ngFor="let eventNames of eventType.events">
  <button ion-item  (click)="goToDrivePage(eventNames.id)">
      {{eventNames.id}}
  </button>
</div>

In ts file get the value

goToDrivePage(id : any){
     console.log(id);
}

Upvotes: 9

Related Questions