2

I show checkboxes on the page.

When I click over it it is changed to true/false. If true the cehckbox should be checked.

Problem is when I click first checkbox it works, when click the second I get wrong completed: false in object {id: 2, content: "CSS", completed: false}, despite checkbox is checked:

pic 1

Code is by link to stackblitz

2 Answers 2

3

You are using ngModel directive wrong its [(ngModel)] not ([ngModel])

Sign up to request clarification or add additional context in comments.

2 Comments

It has no sense, I removed ([ngModel]) the same issue.
Removing ngModel is also issue. You have to use correct syntax
0

Checkboxes has rather a state (checked or not), not a value. If you are changing the model value after click, use checkbox only for showing the curent state. So i would change:

[(ngModel)]="todo.completed"

to [checked]="todo.completed"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.