Angular UI的select2数组是可能的

Angular UI select2 array with objects is it possible?

本文关键字:select2 UI Angular 数组      更新时间:2023-09-26

是否有一个简单的方法有选项作为数组中的对象?如:

$scope.search.categories = [{id: '1',name: 'first'},{id: '2',name: 'last'}];
<select ui-select2 ng-model="search.categories" multiple style="width:300px" data-placeholder="select category">
  <option ng-repeat="category in search.categories" value="{{category}}">{{category.name}}</option>
</select>
还是我完全错了?

查看我制作的演示:http://plnkr.co/edit/gist:4279651?p=preview

如果您希望选择的项目是一个对象,使用<input>

演示向您展示了4种不同的方法来执行uiSelect2