Angular获取表中所选行的数据

时间:2017-09-15 14:10:43

标签: angular

还给出了Angular4 * ngFor tabloda列出。我想获得ID'来自传入数据的信息。我怎么能这样做?

 TNat . Typ4 ::= "nat" ;                                                        
 TVoid . Typ4 ::= "<>" ;    
 TProd . Typ3 ::= SumType;                                
 TProd . Typ2 ::= Typ2 "*" Typ3;                                                
 TArrow . Typ1 ::= Typ1 "->" Typ2;                                              
 coercions Typ 4;      

打字稿

<tbody>
    <tr *ngFor="let item of empleyoo">
        <th scope="row" >{{item.Id}}</th> /*this row data get*/
        <td>{{item.name}}</td>
        <td>{{item.surname}}</td>
        <td>{{item.code}}</td>
       <button type="button" class="glyphicon glyphicon-check"></button>
    </tr>       
<tbody>

1 个答案:

答案 0 :(得分:6)

你的问题不明确,但我想你想要的只是:

<tbody>
    <tr *ngFor="let item of empleyoo">
        <th scope="row" >{{item.Id}}</th> /*this row data get*/
        <td>{{item.name}}</td>
        <td>{{item.surname}}</td>
        <td>{{item.code}}</td>
       <button type="button" (click)="onSelect(item)"class="glyphicon glyphicon-check"></button>
    </tr>
<tbody>);

onSelect(selectedItem: any) {
    console.log("Selected item Id: ", selectedItem.Id); // You get the Id of the selected item here
}