-
Notifications
You must be signed in to change notification settings - Fork 248
ng-change for <select> is invoked before the model is updated #399
Comments
1ab385e can not reproduce, assuming no longer an issue. |
I got the same issue as RobertSzymacha even in Dart SDK version 1.2.0-dev.5.7. |
For temporary bug fix, I need to add a time delay of 1 ms as below to get the correct value: import 'dart:async';
String currentValue = "aaa";
void selectionChanged() {
new Timer(const Duration(milliseconds: 1), () {
print("currentValue $currentValue");
}
} i.e. After selecting "bbb" in the select, controller prints: bbb |
Instead of adding 1 ms delay, you can simply run it in a Future. It's still a hack, but with less overhead (see https://www.dartlang.org/articles/event-loop/). import 'dart:async';
String currentValue = "aaa";
void selectionChanged() {
new Future(() {
print("currentValue $currentValue");
});
} |
same issue on http://stackoverflow.com/questions/22509257 |
The issue is that ng-change and input directive can be registered in any order. Changing from ng-change to on-change fixes the issue, since events are on-change The separate registration model also means that apply() gets run for each element, A proper way to fix this is for EventHandler to handle both the change event for |
NgElement uses EventHandler to register event listeners. Event Handler exposes API to register callbacks, release them as well as a method (walkDomTreeAndExecute) that is used (by TestBed.triggerEvent) to emulate even bubbling when DOM tree is not attached to document.body. ElementProbe is also extended to allow attaching additional listeners. This can be used by different components to programatically attach event handlers (see InputSelectElement and it's change event handler). Closes dart-archive#399
NgElement uses EventHandler to register event listeners. Event Handler exposes API to register callbacks, release them as well as a method (walkDomTreeAndExecute) that is used (by TestBed.triggerEvent) to emulate even bubbling when DOM tree is not attached to document.body. ElementProbe is also extended to allow attaching additional listeners. This can be used by different components to programatically attach event handlers (see InputSelectElement and it's change event handler). Closes #399
NgElement uses EventHandler to register event listeners. Event Handler exposes API to register callbacks, release them as well as a method (walkDomTreeAndExecute) that is used (by TestBed.triggerEvent) to emulate even bubbling when DOM tree is not attached to document.body. ElementProbe is also extended to allow attaching additional listeners. This can be used by different components to programatically attach event handlers (see InputSelectElement and it's change event handler). Closes #399
NgElement uses EventHandler to register event listeners. Event Handler exposes API to register callbacks, release them as well as a method (walkDomTreeAndExecute) that is used (by TestBed.triggerEvent) to emulate even bubbling when DOM tree is not attached to document.body. ElementProbe is also extended to allow attaching additional listeners. This can be used by different components to programatically attach event handlers (see InputSelectElement and it's change event handler). Closes #399
PR is too old to be useful and we have no immediate plans to work on this. |
I also have the same problem. |
model update will not trigger change on my guess is that it has to do something with selected="true" <option selected="true" ng-repeat="st in stations | orderObjectBy: 'StationName' | filter: {isAirport:true}" value="{{st._id}}">{{st.StationName}}</option> |
I have following component template:
And the component's dart code:
After selecting "bbb" in the select, controller prints:
while it should print "currentValue bbb"
The text was updated successfully, but these errors were encountered: