<h1 class="mat-display-1">Students</h1>
<button mat-raised-button color="primary" (click)="openDialog()">Add</button>
<button mat-raised-button color="primary" (click)="delete()">Remove</button>
<br>
<mat-form-field appearance="fill">
  <mat-label>Filter</mat-label>
  <input matInput (keyup)="applyFilter($event)" #filter>
</mat-form-field>

<table *ngIf="studentList" mat-table [dataSource]="studentList" matSort>
  <ng-container matColumnDef="select">
    <th mat-header-cell *matHeaderCellDef>
      <mat-checkbox (change)="$event ? masterToggle() : null"
                    [checked]="selection.hasValue() && isAllSelected()"
                    [indeterminate]="selection.hasValue() && !isAllSelected()"
                    [aria-label]="checkboxLabel()">
      </mat-checkbox>
    </th>
    <td mat-cell *matCellDef="let row">
      <mat-checkbox (click)="$event.stopPropagation()"
                    (change)="$event ? selection.toggle(row) : null"
                    [checked]="selection.isSelected(row)"
                    [aria-label]="checkboxLabel(row)">
      </mat-checkbox>
    </td>
  </ng-container>

  <ng-container matColumnDef="firstname">
    <th mat-header-cell *matHeaderCellDef mat-sort-header="firstname">Firstname</th>
    <td mat-cell *matCellDef="let student"> {{student.firstname}} </td>
  </ng-container>

  <ng-container matColumnDef="lastname">
    <th mat-header-cell *matHeaderCellDef mat-sort-header="lastname">Lastname</th>
    <td mat-cell *matCellDef="let student"> {{student.lastname}} </td>
  </ng-container>

  <ng-container matColumnDef="email">
    <th mat-header-cell *matHeaderCellDef mat-sort-header="email">Email</th>
    <td mat-cell *matCellDef="let student"> {{student.email}} </td>
  </ng-container>

  <ng-container matColumnDef="telephone">
    <th mat-header-cell *matHeaderCellDef mat-sort-header="telephone">Telephone</th>
    <td mat-cell *matCellDef="let student"> {{student.telephone}} </td>
  </ng-container>

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

  <tr class="mat-row" *matNoDataRow>
    <td class="mat-cell" colspan="5">No data matching the filter "{{filter.value}}"</td>
  </tr>
</table>

<mat-paginator [pageSizeOptions]="[5, 10, 20]"
               showFirstLastButtons
               aria-label="Select page">
</mat-paginator>


