click event triggers before ng-model changes the value.
See original GitHub issueI am doing something like this.
<input [(ng-model)]="item.completed" (click)="completed(i)" type="checkbox">
What i want is the when checkbox is clicked it changes the value of item.completed and then it fires the click event.
But what happening is. click events get fired and then ng-model changes the value of item.completed.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:7
- Comments:35 (8 by maintainers)
Top Results From Across the Web
ngModelChange triggers before the model is actually changed
You can pass the social object as part of modelChange event. Inside component, using event you can check whether checked ...
Read more >Difference between (change) and (ngModelChange) in Angular
In this post we're going to cover the difference between (change) and (ngModelChange) events with an inside an Angular component.
Read more >ngModelChange and change events in Angular with examples
Whenever a change happens in ngModel , Angular will trigger ngModelChange ... ngModelChange event parameter contains the changed value.
Read more >What is the difference between change and ngModelChange ...
ngModelChange: When the user wants to change the model, by entering text into the input, the event callback fires and sets the new...
Read more >NgModelChange & Change Event in Angular - TekTutorialsHub
It is the @Output property of the ngModel directive, Hence we need to use it along with it. ngModle raises the NgModelChange event,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
click
is a DOM event, not related to the higher levelngModel
. The proper event for this isngModelChange
. If you want to use DOM events, then forget about ngModel and use$event
inside the handler or a#ref
.So, instead of
it should be
Another workaround that seems to work fine is to wrap everything in your OnChange method in a setTimeout(() => { dostuff });