【发布时间】:2013-01-21 13:24:28
【问题描述】:
以下数据通过Angular UI附加到select2:(Live example here)
JS:
$scope.items = [
{id: 1, text: 'elephant'},
{id: 2, text: 'desk'},
{id: 3, text: 'car'},
{id: 4, text: 'boat'},
{id: 5, text: 'apple'}
];
$scope.selected = [];
HTML:
<select ui-select2
multiple
ng-model="selected"
data-placeholder="Please select..."
style="width:200px">
<option></option>
<option ng-repeat="item in items" value="{{item.id}}">{{item.text}}</option>
</select>
但是,每次选择项目时,它都会按id 对所选项目进行排序。例如,如果您选择“apple”然后选择“boat”,则selected 项目将是“boat”和“apple”(按此顺序!)。
如何保留订单并禁用自动排序?
【问题讨论】:
-
Select2 中的 vanilla JS 会发生这种情况,还是仅 AngularUI 会发生这种情况?
-
我完全不确定为什么会这样。你能开一个项目的票吗?
-
@ProLoser: github.com/angular-ui/angular-ui/issues/406
标签: angularjs jquery-select2 angular-ui