Just for the future
we should note that [(ngModel)] = "hero.name" is just the shortest path that can be removed from scratch: [ngModel] = "hero.name" (ngModelChange) = "hero.name = $ event".
So if we remove the code from sugar, we get:
<select (ngModelChange)="onModelChange()" [ngModel]="hero.name" (ngModelChange)="hero.name = $event">
or
<[ngModel]="hero.name" (ngModelChange)="hero.name = $event" select (ngModelChange)="onModelChange()">
If you inspect the above code, you will notice that in the end we have 2 ngModelChange events that must be executed in some order.
To summarize : if you put ngModelChange before ngModel, you will get the $ event as a new value, but your model object will still have the previous value. If you put it after ngModel, the model will already have a new value.
SOURCE
source share