jeudi 5 avril 2018

Angular: Uncheck Checkbox With [(ngModel)]

I have a form that contains a checkbox when I add [(ngModel)] to the tag, the checkbox will be automatically checked when the page load

 <input type="checkbox" name="test" id="test" [(ngModel)]="model.test" value="1"> is

I tried to fix this using

  ngOnInit() {
   let test = document.getElementById('test') as HTMLInputElement;
   test.checked = false;
  }

in the .ts but didn't work

is there any way I can make the checkbox unchecked in the loading of the page?

Aucun commentaire:

Enregistrer un commentaire