Turn html page id inside ngFor to page ts

1

I have an * ngFor of an array object, I want to pass the id inside the button to the typescript for configuralos as links in a modal. Here is the syntax that I'm trying with no success:

<ion-item *ngFor="let item of itens">
    <ion-thumbnail item-left>
      <img src="../assets/img/{{item.img}}">
    </ion-thumbnail>
    <h2>{{item.nome}}</h2>
    <p>{{item.categ}}</p>
    <button id="{{item.id}}" ion-button clear item-right (click)="chamaProd()">ver</button>
  </ion-item>
    
asked by anonymous 26.01.2017 / 22:37

1 answer

3

Try to do this:

HTML:

 (click)="chamaProd(item)" 

So you will pass the entire object of the list to your chamaProd method.

TS:

  chamaProd(item : <<Objeto da Lista>>){
.
. /* No corpo do metodo vc faz oque quiser, pois, vc tem a instancia do objeto clicado em tela */
}  
    
01.02.2017 / 15:36