【发布时间】:2016-06-02 21:53:02
【问题描述】:
我正在使用 angular-ui 的 select2 组件,无论我使用单选还是多选,我都希望我的模型具有一致的值。
目前,如果我使用单选,模型只是设置为一个值,当使用多选时,模型是一个值数组。
IE单选:(非数组模型)
<ui-select ng-model="model.value" theme="bootstrap">
<ui-select-match>{{$select.selected.title}}</ui-select-match>
<ui-select-choices repeat="choice.title as choice in choices | filter: $select.search">
<div ng-bind-html="choice.title | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
或多:(数组模型)
<ui-select multiple ng-model="model.value" theme="bootstrap">
<ui-select-match>{{$item.title}}</ui-select-match>
<ui-select-choices repeat="choice.title as choice in choices">
<div ng-bind-html="choice.title"></div>
</ui-select-choices>
</ui-select>
我尝试使用多个,并添加 length="1" 属性,但是仍然将多选样式应用于选择框。
即使在单选时也可以从 select2 中获取数组模型吗?
【问题讨论】:
标签: angularjs angular-ui select2