2

So i have this ui-select which works fine but I want the dropdown list to only show or be populated upon minimum 2 characters input hwo do i do this?

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

Any answer is appreciated

Kingsley Simon
  • 2,090
  • 5
  • 38
  • 84
  • Maybe a Typeahead is what you are looking for. See here: https://angular-ui.github.io/bootstrap/ – Neil Oct 28 '15 at 21:56

1 Answers1

2

Try something like this:

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

Then in your controller add something like this:

$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;
 }
glthomas
  • 105
  • 1
  • 7