1

所以我有这个 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>

任何答案表示赞赏

4

1 回答 1

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;
 }
于 2015-11-10T17:06:32.017 回答