lundi 20 novembre 2017

Setting checkbox value in angular after initialization

So I have this checkbox, I have binded ngModel to it and based on the ngModel it properly sets the checkbox as checked or unchecked.

The problem is, if I change the checkbox, I check for some conditions and based on some that condition I make the ngModel binded to it false again, so technically it should go back to unchecked state if it was checked and the condition satisfied, but it's not. Although my ngModel shows a value of false.

Even tried with the [checked] attribute, but it's also not working.

Any inputs are highly appreciated

<input type="checkbox" [(ngModel)]="isChecked" [checked]="isChecked" (ngModelChange)="onChange('statusPush',$event)">

in Component

if(someCondition) {
this.isChecked = false
}




Aucun commentaire:

Enregistrer un commentaire