obtenez de l'indice de la ligne dans angulaire de la table de matériaux v5

Je vais essayer d'obtenir l'indice de ligne dans la table, en html, qui a été mis en œuvre à l'aide angulaire matériel v5.2. Est-il une méthode pour obtenir l'index?

Le code de référence:

<div class="example-container mat-elevation-z8">
  <div class="example-header">
    <mat-form-field>
      <input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
    </mat-form-field>
  </div>

  <mat-table #table [dataSource]="dataSource">

    <!-- Position Column -->
    <ng-container matColumnDef="position">
      <mat-header-cell *matHeaderCellDef> No. </mat-header-cell>
      <mat-cell *matCellDef="let element"> {{element.position}} </mat-cell>
    </ng-container>

    <!-- Name Column -->
    <ng-container matColumnDef="name">
     <button (click)="doSomething()"> Do something</button>
    </ng-container>

    <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
    <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
  </mat-table>
</div>

La méthode doSomething est ce que les besoins de l'index.

Toute aide serait grandement appréciée.

InformationsquelleAutor Shivi | 2018-05-11