我在頁面上有多個UI選擇。如何分別爲每個項目設置選定值,從而使用從服務中檢索的單個列表?Angularjs ui-select:如何爲多個下拉列表設置選定的值
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);
});
這將設置兩個下拉列表的值... –
是啊,這是有道理的,你必須使每個模型的每個選擇框,只有這樣 –