Child component contains an Angular material table, that is created based on columns passed as input:
<table mat-table>
<ng-container *ngFor="let col of columns" [matColumnDef]="col">
</table>
@Input() columns: string[]
Parent component passes columns definitions. However, the only way I can affect f.e. mat table column width
is by setting the stylesheet with
.mat-column-col-name {
width: 10px
}
How can I set mat-column width
from the parent component? Names of columns are variables. I strongly want to avoid any encapsulation: none
, because child component is inside a library I develop. Passing styles as @Input()
would be the best solution.