我的用户对象如下所示:
var users = {
1: 'John Doe',
7: 'Marry Match',
13: 'Lindsay Lohan'
};
使用1,7和13作为用户ID和名称......好吧,作为名字。
我如何在ui-select 中填写我的用户下拉列表?
我已尝试过以下
<ui-select ng-model="selectedUser" theme='select2' title="Choose a user">
<ui-select-choices repeat="(id, name) in users | filter: $select.search">
<span ng-bind="name"></span>
</ui-select-choices>
</ui-select>
答案 0 :(得分:0)
github有一个object-as-source-example,并将重复字符串描述为:
person.key as (key, person) in peopleObj
考虑到这一点,请尝试:
<ui-select ng-model="selectedUser" theme='select2' title="Choose a user">
<ui-select-choices repeat="name.id as (id, name) in users | filter $select.search">
<span ng-bind="name"></span>
</ui-select-choices>
</ui-select>