Skip to content

Angular Checkbox doesn't check

jwp profile image John Peters github logo ・1 min read

Try this binding first

      (change)="onCheckBoxChanged(checkbox, setting)"
      [checked]="setting.values[0] != 'false'"       

Where the variable setting is a part of a parent *ngFor loop. This is different than other [(ngModel)] bindings; in that, we are going directly to the input checked attribute. What's interesting is that we had to add the comparator to get it to work.

[checked]="setting.values[0] != 'false'"  

Even though setting.values[0] only had string values of "true" and "false" binding directly to it like these two statements:


Did not work! Not sure why, but I do know it can chew up time finding these syntactic errors.


twitter logo DISCUSS
markdown guide
Classic DEV Post from Aug 4 '19

You're not worth hiring unless...

John Peters profile image
Angular, React, Typescript and JavaScript. The wave of now!