mercredi 27 janvier 2021

Bind angular mat-checbox ngModule

I have an Array of mat-checbkox, where user can only select one option:

export enum ProjectStatus {
  Ready = "Is ready",
  Testing = "is testing",
  Done = "is done"
}

<div *ngFor="let status of projectStatus; let i=index">
    <mat-checkbox [checked]="selected.index === i"
        (change)="selected.index = i; selected.status=status; selected.checked= true;">
    </mat-checkbox>
</div>

Then I got some others mat-checkbox:

<div>
    <mat-checkbox>SEND REPORTS</mat-checkbox>
</div>
<div>
    <mat-checkbox>WARN DEVELOPERS</mat-checkbox>
</div>
<div>
    <mat-checkbox>WARN PROJECT MAANGER</mat-checkbox>
</div>
<div>
    <mat-checkbox>WARN TESTERS</mat-checkbox>
</div>

My question is, how I can check another mat-checkbox dynamically based on the first checkbox list checked. I have to use ngModule?

For example, If I select:

is Testing

I want to check automatically the checkboxs:

SEND REPORTS
WARN DEVELOPERS

enter image description here

That's the link of the testing application: https://stackblitz.com/edit/angular-vrnk7t-bxeplb?file=src%2Fapp%2Fcheckbox-overview-example.html




Aucun commentaire:

Enregistrer un commentaire