簡體   English   中英

當我們使用角度和離子單擊按鈕時,如何獲取ID?

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

我正在使用下面的代碼,並且單擊時沒有獲得ID。

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

任何機構都可以幫助我獲取功能中的ID?

將id值傳遞給函數

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

在ts文件中獲取值

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM