0

When a user selects an option, a different option shows up as the selected option. This only occurs with select2 enabled. However, ng-model will correctly behave as expected, so the select will display a different option to what ng-model reports.

Notably, if i click on the option a second time, it will correctly select and display the item I want and the selection and model will be in sync

example
<select class="form-control" ui-select2 class="select2El" ng-model="schedule.deviceid" ng-options="device.deviceid as device.name for device in devices"></select>

Where devices is an array of objects.

if I click the first option shown (say option with id: 1), a completely unrelated option (option with id: 30) will display as the selected item. Ng-model will show option 1.

if I click on the intended first option a second time, it will now correctly display.Ng-model will still show option 1.

Versions:

  • angular#1.2.16
  • select2#3.4.6
2

1 Answer 1

1

ui-select2 docs says it's not compatible with ng-options.

github.com/angular-ui/ui-select2#working-with-dynamic-options

you should use ng-repeat.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.