在Angular Material表中,我们在组件文件中定义displayColumns,然后在html模板中应用它们。有什么方法可以根据屏幕大小动态分配displayColumns的值?
在移动设备上显示表格时,我只希望显示2或3列。
// part of component.ts
displayedColumns = ['compName', 'city', 'state', 'compCat', 'compSubcat', 'compClass', 'options'];
//part of html
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>