Вы можете попробовать мой код:
in. html:
<mat-card>
<mat-card-content>
<h2 class="example-h2">Checkbox configuration</h2>
<section class="example-section">
<mat-checkbox (click)="CheckAllOptions()"class="example-margin" [(ngModel)]="checked">Checked</mat-checkbox>
</section>
<div *ngFor="let checkbox of checkboxes">
<input type="checkbox" [(ngModel)]="checkbox.checked" [value]="checkbox.value"><span>{{checkbox.name}}</span>
</div>
</mat-card-content>
</mat-card>
в .ts в классе экспорта:
checkboxes: any[] = [
{ name: 'cb1', value: 'cb1', checked: false },
{ name: 'cb2', value: 'cb2', checked: true },
{ name: 'cb3', value: 'cb3', checked: false },
{ name: 'cb4', value: 'cb4', checked: false },
{ name: 'cb5', value: 'cb5', checked: false },
]
CheckAllOptions() {
if (this.checkboxes.every(val => val.checked == true))
this.checkboxes.forEach(val => { val.checked = false });
else
this.checkboxes.forEach(val => { val.checked = true });
}