bentorfs / angular-bootstrap-multiselect

Native angularJS custom form element
http://bentorfs.github.io/angular-bootstrap-multiselect/
MIT License
79 stars 111 forks source link

ng-change fired twice? #59

Open AnimaLupi opened 6 years ago

AnimaLupi commented 6 years ago

Hello, I'm trying to use ng-change with this directive.

I've noticed that from time to time the ng-change callback gets called twice.

I think this happens when the newly selected option is being added among the selected ones and that triggers a reordering of the array (i.e. the newly selected option gets inserted in the middle or the start of the selected options).

The model is first updated with the newly selected option at the end (1st on-change), then it's sorted to proper order (2nd on-change).

Thank you,

Andrea

ljluestc commented 10 months ago
<select ng-model="selectedOption" ng-options="option for option in options" ng-change="handleSelectionChange()">
  <option value="">Select an option</option>
</select>