所以我有这个ui-select工作正常,但我希望下拉列表只显示或填充至少2个字符输入我会这样做吗?
<ui-select name="organization_chosen" ng-model="user.organization_chosen.selected" theme="selectize" class="form-control ng-pristine ng-invalid ng-invalid-required" style="margin-top: -5px; margin-left: 7px;" required >
<ui-select-match placeholder="Organization Name" style="position: static;">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="item in rea_list | filter: $select.search |limitTo: 20">
<div ng-bind-html="item.name | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
感谢任何回答
答案 0 :(得分:2)
尝试这样的事情:
<ui-select-choices repeat="item in delayed_rea_list track by $index | filter: $select.search | limitTo: 20" refresh="refresh_rea_list($select.search)"
refresh-delay="0">
<div ng-bind-html="item.name | highlight: $select.search"></div>
</ui-select-choices>
然后在你的控制器中添加如下内容:
$scope.delayed_rea_list = [];
$scope.refresh_rea_list = function(input) {
if(angular.isUnDefined(input) || input == null) return [];
if(input.length < 2) return [];
$scope.delayed_rea_list = $scope.rea_list
return $scope.delayed_rea_list;
}