如何获取angular4-data-table中选择的行的索引

时间:2019-01-09 20:16:25

标签: indexing row selected

我在我的应用程序中使用angular4-data-table。 我的[indexColumn]为“ false”,因此不显示行号。 我如何获取所选行的索引并将其传递给typescript类。 每列都用ng-template /

包围
<data-table [header]="false" [items]="items" [itemCount]="elemetcount"
    [multiSelect]="false" [substituteRows]="false"
    [showOnTop]="true" [indexColumn]="false" [selectOnRowClick]="true"
    (rowClick)="rowClick($event)"    >
      <data-table-column
        [property]="'checked'">
            <ng-template let-item="item"> 
          <input type="checkbox" [checked]="item.checked"  (click)="keyDown(item)" /> //pass index of selected item
        </ng-template>
    </data-table-column>

component.ts

keyDown(item) {
// I want to get the index of selected row
}

0 个答案:

没有答案
相关问题