Trying to check the mat checkbox by passing the values, But it is not working. If i click the button checkbox should be checked by passing the values. So, How to do it? If anyone knows please help to find the solution.
app.component.ts:
checkValues(val: any) {
let getVal = val.split(',');
getVal.forEach((element: any) => {
this.cardValue.options.push(element);
console.log(element);
});
}
app.component.html:
<mat-card class="card-wrapper">
<app-mauto
#child
placeholder="Select Items Here ..."
key="options"
[data]="selectOptions"
(result)="selectChange($event)"
>
</app-mauto>
</mat-card>
<div class="btnBox">
<button (click)="checkValues('Car,Bus')">Select Checkbox Car and Bus</button>
<button (click)="checkValues('Motor,Bus')">
Select Checkbox Motor and Bus
</button>
<button (click)="checkValues('Wheel,Bus')">
Select Checkbox Wheel and Bus
</button>
</div>
Demo : https://stackblitz.com/edit/angular-ivy-xhg8k2?file=src%2Fapp%2Fshared%2Fmauto%2Fmauto.component.ts