I am using mat-table, the displayed columns are defined in the following array:
TypeScript:
displayedColumns: string[] = ['date', 'customer', 'project', 'performanceRecord', 'duration', 'status', 'action'];
HTML:
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
For mobile phones, i would like to remove some columns and replace the displayedColumns with displayedColumnsForMobilePhones:
displayedColumnForMobilesPhones: string[] = ['date', 'customer', 'project'];
So i would like to know whether there is a way to change the displayed columns depending on screen size. Is something like this possible?
<tr mat-header-row *matHeaderRowDef="getScreenSize() > XS ? displayedColumn : displayedColumnForMobilePhones; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: getScreenSize() > XS ? displayedColumn : displayedColumnForMobilePhones;"></tr>
Or is there any other way to figure out the screensize and adjust the displayedColumn array accordingly? Anything would work, thanks.