angular2 material table hide column

no need of any directives.

just use

[hidden]
it will work
ex:[hidden]=”show” in html
and
set show to boolean in ts file.

my html code:

<ng-container matColumnDef="department" >
  <mat-header-cell [hidden]="show" *matHeaderCellDef> 
    Department 
  </mat-header-cell>
  <mat-cell [hidden]="show" *matCellDef="let element">
    {{element.department}}
  </mat-cell>
</ng-container>

Leave a Comment