使用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
而不是整个对象。
我该怎么做?
更改您的 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"
请参阅此处的更多信息