在设置最小输入字符后显示ui选择下拉列表



所以我有这个ui选择,它很好用,但我希望下拉列表只显示或填充至少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>

任何答案都很感激

试试这样的东西:

<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;
 }

最新更新