Angular UI select2 - How to stop automatic sorting? Angular UI select2 - How to stop automatic sorting? angularjs angularjs

Angular UI select2 - How to stop automatic sorting?


Looks like it preserves the order if you use ng-options instead of doing an ng-repeat for each of the items like seen here

All you have to do is delete this line:

<option ng-repeat="item in items" value="{{item.id}}">{{item.text}}</option>

And then add a directive like this to your tag:

ng-options="item.text for item in items"

This will make it so the entire item object gets appended to the selected list, instead of just the ID, so you will need to take that into account.