[英]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.