mercredi 8 mai 2019

How can I automatically recheck a checkbox that has been unchecked using angular

I have a checkbox that a user can uncheck or check. when the user unchecks it, I want to automatically check it using angular

I'm using angular 7.

template code:

  type="checkbox"
  [(ngModel)]="CheckBoxValue"
  (ngModelChange)="onChangeCheckBox(CheckBoxValue)"/>

component event to recheck if unchecked:

  public onChangeCheckBox(value: boolean): void {
    if (!value) {
      this._checkBoxValue = true;
      console.log("I have been there");
    }
  }

here s link to my code: https://stackblitz.com/edit/angular-tgud2c

You may Ask what do I want to do this? My original question was more complex. I have tried my best to simplify it. You can find it here




Aucun commentaire:

Enregistrer un commentaire