Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng-change fired twice? #59

Open
AnimaLupi opened this issue Oct 10, 2017 · 1 comment
Open

ng-change fired twice? #59

AnimaLupi opened this issue Oct 10, 2017 · 1 comment

Comments

@AnimaLupi
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants