最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Angular UI select2 array with objects is it possible? - Stack Overflow

programmeradmin2浏览0评论

Is there a easy way to have options as objects in array? Like following:

$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>

Or am I totally wrong?

Is there a easy way to have options as objects in array? Like following:

$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>

Or am I totally wrong?

Share Improve this question edited Mar 28, 2013 at 21:43 j0k 22.8k28 gold badges81 silver badges90 bronze badges asked Jan 15, 2013 at 10:44 Jakub KucharJakub Kuchar 1,6652 gold badges23 silver badges40 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Checkout this demo I've put together: http://plnkr.co/edit/gist:4279651?p=preview

If you want the selected item to be an object use <input>

The demo shows you 4 different ways to do uiSelect2

发布评论

评论列表(0)

  1. 暂无评论