implementing ng-if directive inside md-table
The problem is that you're using two structural directives with an asterisk syntax on one element. You need to unwrap one of them. The following should work:
<ng-template [ngIf]="!(authService.isAdmin())">
<md-cell *cdkCellDef="let row">
<button md-button (click)="viewNarrative(row)"><md-icon>toc</md-icon> Narrative</button>
<button md-button (click)="editDemographics(row)"><md-icon>edit</md-icon> Demographics</button>
<button md-button (click)="confirmDelete(row, $event)" style="line-height:normal"><md-icon>delete</md-icon> Delete</button>
</md-cell>
</ng-template>
Or simply move ngIf
to the ng-container
:
<ng-container *ngIf="!(authService.isAdmin())">
<md-cell *cdkCellDef="let row">
you can do something like:
This allows you to have the mat-cell and an *ngIf too
<ng-container matColumnDef="isActive">
<mat-header-cell *matHeaderCellDef mat-sort-header> Active </mat-header-cell>
<mat-cell *matCellDef="let element"> <mat-icon *ngIf="element.isActive;else notactive;">done</mat-icon>
<ng-template #notactive><mat-icon>clear</mat-icon></ng-template>
</mat-cell>
</ng-container>