使用ui-select,我有个人列表,并希望通过这种方式显示ui-select
:
(function() {
'use strict';
angular
.module('framework')
.controller('UserDetailController', UserDetailController);
function UserDetailController(BasePersonel) {
var vm = this;
vm.basePersonels = BasePersonel.all();
}
})();
<ui-select ng-model="vm.basePersonelId" >
<ui-select-match>
<span ng-bind="$select.selected.entityTitle"></span>
</ui-select-match>
<ui-select-choices repeat="item in (vm.basePersonels | filter: $select.search) track by item.id">
<span ng-bind="item.entityTitle"></span>
</ui-select-choices>
</ui-select>
但我想将所选对象的id
设置为vm.basePersonelId
而不是整个对象。
我该怎么做?
答案 0 :(得分:1)
更改您的 repeat
repeat="item in (vm.basePersonels | filter: $select.search) track by item.id"
到此:
repeat="item.id as item in (vm.basePersonels | filter: $select.search) track by item.id"
查看更多here