<ui-select id="facility" multiple ng-model="IdRequest.formData.facilityRequestedArray" validation="required" ng-disabled="IdRequest.formData.applicantReadOnly" class="drop-down">
<ui-select-match allow-clear="true" placeholder="{{'select'|translate}}">
{{$item.displayText}}
</ui-select-match>
<ui-select-choices repeat="facility.id as facility in IdRequest.facilityList">
{{facility.displayText}}
</ui-select-choices>
</ui-select>
错误:[ngRepeat:dupes]不允许在转发器中重复。使用'track by'表达式指定唯一键。 Repeater:$ select.selected中的$ item,Duplicate key:number:1,Duplicate value:1
答案 0 :(得分:0)
将您的倍数设置为true,如下所示:
<ui-select id="facility" multiple='true' ng-model="IdRequest.formData.facilityRequestedArray" validation="required" ng-disabled="IdRequest.formData.applicantReadOnly" class="drop-down">
请参阅此github链接:https://github.com/angular-ui/ui-select/issues/366
如果您有重复的设施,也可以通过$ index为您的转发器添加跟踪:
<ui-select-choices repeat="facility.id as facility in IdRequest.facilityList track by $index">
答案 1 :(得分:0)
我和ui-select(版本2.1.3)有同样的问题。所选项目通过ajax加载,将显示正确的选项,但单击选择另一个选项时,已选择的选项在可能的选项内,再次选择时,将触发重叠错误。
我决定不深入挖掘源代码,而是强制从脚本中刷新指令。
这是修复: HTML
<ui-select multiple="true" ng-model="x.itemsSelected" theme="bootstrap">
<ui-select-match placeholder="Select Eligibility Item...">{{$item.name + ' #' + $item.id}}</ui-select-match>
<ui-select-choices repeat="item.id as item in x.itemsAvailable | filter: $select.search track by $index" refresh="uiSelectRefreshFix($select)" refresh-delay="1000">
<div ng-bind-html="item.name + ' #' + item.id | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
控制器
// ui-select bugfix.
$scope.uiSelectRefreshFix = function () {
if ($scope.uiSelectFix) return;
$scope.uiSelectFix = true;
var fix = $scope.x.itemsSelected;
$scope.x.itemsSelected = [];
setTimeout(function() {
$scope.$apply(function(){
$scope.x.itemsSelected = fix;
});
}, 100)
console.log([model, query]);
}