我在页面上有多个 ui 选择。如何分别为每个项目设置选定值,从而使用从服务中检索的单个列表?
HTML:
<div class="col-sm-4">
<ui-select class="col-sm-12 no-padding" ng-model="mappingStrengthList.selected">
<ui-select-match placeholder="Choose strength">
<span ng-bind="$select.selected.name"></span>
</ui-select-match>
<ui-select-choices repeat="item in (mappingStrengthList | filter: $select.search) track by item.id">
<span ng-bind="item.name"></span>
</ui-select-choices>
</ui-select>
</div>
<div class="col-sm-4">
<ui-select class="col-sm-12 no-padding" ng-model="mappingStrengthList.selected">
<ui-select-match placeholder="Choose strength">
<span ng-bind="$select.selected.name"></span>
</ui-select-match>
<ui-select-choices repeat="item in (mappingStrengthList | filter: $select.search) track by item.id">
<span ng-bind="item.name"></span>
</ui-select-choices>
</ui-select>
</div>
控制器:
ListService.getList('mapping-strength').then(function (results) {
$scope.mappingStrengthList = results;
}, function (error) {
console.log(error);
});