Issue
I have this code:
<ng-container matColumnDef="Estado">
<th mat-header-cell *matHeaderCellDef>Estado</th>
<td mat-cell *matCellDef="">
<mat-checkbox *ngIf=!state mat-checked></mat-checkbox>
</td>
</ng-container>
When the condition in the *ngIf
is met the checkbox appears unchecked, but I need to get it already checked, I don’t know how, hope you can help me, thank you.
Solution
The mat-checkbox component has a input called ‘checked’
Try something like that:
<ng-container matColumnDef="Estado">
<th mat-header-cell *matHeaderCellDef>Estado</th>
<td mat-cell *matCellDef="">
<mat-checkbox *ngIf="!state" [checked]="true"></mat-checkbox>
</td>
</ng-container>
It’s always a good idea to check the API tab in the documentation of the component you are using