![](/img/trans.png)
[英]How to make class binding on an angular table row using table row index to match elements of component array
[英]How to get Table(array)index in to component in Angular
为index
设置一些其他变量,并在您的(单击)处理程序中使用它们:
<tbody>
<tr *ngFor="let subarray of myarray2; let i = index;">
<td *ngFor="let item of subarray; let j = index;">
{{item}}
<span tabindex="0" (click)="someMethod(i, j)">+</button>
</td>
</tr>
</tbody>
我设法在注释的帮助下获取了参数。这个也可以。非常感谢
html
<tbody>
<tr *ngFor="let i of myarray2 ; let indx1 = index" [attr.data-index]="indx1">
<td *ngFor="let j of i ; let indx2 = index" [attr.data-index]="indx2" > {{j}}
<button *ngIf="j=='0.0 h'" (click)="getIndexofTable(indx1, indx2)" class="fa fa-plus" > </button>
</td>
</tr>
打字稿
getIndexofTable(index_value:number,index_value2:number){}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.