title: get index of row in angular material table v5
body: <p>I'm trying to get the index of row in table, in html, which has been implemented using angular material v5.2. Is there any method available to get the index?</p>
  
  <p>The code for reference:</p>
  
  <pre><code>&lt;div class="example-container mat-elevation-z8"&gt;
    &lt;div class="example-header"&gt;
      &lt;mat-form-field&gt;
        &lt;input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter"&gt;
      &lt;/mat-form-field&gt;
    &lt;/div&gt;
  
    &lt;mat-table #table [dataSource]="dataSource"&gt;
  
      &lt;!-- Position Column --&gt;
      &lt;ng-container matColumnDef="position"&gt;
        &lt;mat-header-cell *matHeaderCellDef&gt; No. &lt;/mat-header-cell&gt;
        &lt;mat-cell *matCellDef="let element"&gt; {{element.position}} &lt;/mat-cell&gt;
      &lt;/ng-container&gt;
  
      &lt;!-- Name Column --&gt;
      &lt;ng-container matColumnDef="name"&gt;
       &lt;button (click)="doSomething()"&gt; Do something&lt;/button&gt;
      &lt;/ng-container&gt;
  
      &lt;mat-header-row *matHeaderRowDef="displayedColumns"&gt;&lt;/mat-header-row&gt;
      &lt;mat-row *matRowDef="let row; columns: displayedColumns;"&gt;&lt;/mat-row&gt;
    &lt;/mat-table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The method doSomething is what needs index. </p>
  
  <p>Any help would be greatly appreciated.</p>