R
R
rusher872016-10-17 14:09:23
JavaScript
rusher87, 2016-10-17 14:09:23

How to display data correctly (angular)?

I output the data like this:

<ul class="regions-result">
          <li class="result" ng-repeat="user in UserList | filter:mySearchFilter(userSearchQueryString)" ng-click="toggleUser(user)">
            <a href="javascript:void(0)" ng-bind="user.name"></a>
          </li>
        </ul>

There is a filter:
<input placeholder="Введите имя пользователя" ng-model="userSearchQueryString" uib-typeahead="name for name in names | filter:$viewValue:startsWith" typeahead-append-to-body="true" class="user-search-block__input form-control" id="user-search" autofocus AUTOCOMPLETE="off"/>

If you entered less than 3 characters in input, then the filter is not applied:
scope.mySearchFilter = function(searchText) {
        if (searchText.length < 3) {
          return ''
        } else {
          return searchText
        }
      };

How can I make it so that no results are displayed at all if less than 3 characters are entered in the input field?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question