lundi 16 janvier 2023

How to uncheck the previous selected mat checkbox based on single check

I'm trying to uncheck a previous selected checkbox based on clicking one new mat checkbox

My HTML:

  <form [formGroup]="deleteform" (submit)="submit()">
    <ul>
      <li *ngFor="let test of getvalue?.food">
        <mat-checkbox [disableRipple]="true" [value]="test.id" [name]="'test.id'"
          aria-label="Value">
        </mat-checkbox>
      </li>
      <mat-checkbox (change)="unCheckAll($event)">None of Above
      </mat-checkbox>
    </ul>
    <button>
      submit <br>
    </button>
  </form>

MY TS:

deleteform: FormGroup;

unCheckAll($event) {
  this.deleteform.reset();
}

So far I tried this but it's not working, Any solution to uncheck previous selected checkbox based on clicking a new checkbox.




Aucun commentaire:

Enregistrer un commentaire