I have started building an ToDo sample app. I am facing an strange issue.
Below is the HTML code for the ToDo List. In that list i am setting ngModel for checkbox and firing an change event as well.
Code to listen the change. I am only printing the current state to console.
Look at below image you can see the current state of the checkbox is checked but in console i am getting the previous state of the checkbox.
Please tell me what is the correct approach to have that working.
This is a known issue
This is working as intended. When the change event is emitted
(...) part of
[(ngModel)] hasn't updated the bound model yet:
There are different workarounds like using
event.target.value instead of the value from the model.