Search code examples
htmlangularangular-materialmat-table

How to find the width of Mat-Table after it is rendered?


I use Angular Material Mat-Table with Angular 8 and pass the dataSource dynamically. The number of rows and column differ each time. Is there a way to find the width of the table rendered on the screen after it is generated?

<mat-table [dataSource]="dataSource" #reportTable>
...
...
...
</mat-table>

Solution

  • Maybe you can put the template reference and width @viewChild decorator refer to element nativelement property and there you can get the width of table. Sorry for my poor English)