V
V
Vitaly2015-07-16 15:27:50
JavaScript
Vitaly, 2015-07-16 15:27:50

How to write autocompete / search with a dropdown list in angular that will work with a large array of data?

I'm trying to make a simple autocoplete, maybe not quite right but ....
here is my html code:

<input type="search" placeholder="Search" ng-model="stationSearch.val">
 <button class="button" ng-click="setStation(bn.name)" ng-repeat="bn in itemsList | filter:stationSearch.val">
              {{bn.name}}
          </button>

and controller code:
$scope.stationSearch = {}'';
 $scope.setStation = function(bnn){
            $scope.stationSearch.val = '';
            $scope.stationSearch.val = bnn;
};

$http.get('http://serverUrl/')
   .success(function(data){
      $scope.itemsList = data;
    })

after response $scope.itemsList is :
$scope.itemsList = [
            {'name': 'Iapetos Baltazar', 'amount': 1},
            {'name': 'Mordred Maui', 'amount': 4},
            {'name': 'Verethragna Tane', 'amount': 20},
            {'name': 'Arawn Lir', 'amount': 7},
            {'name': 'Cepheus Zephyrus', 'amount': 15},
            {'name': 'Leander Pallas', 'amount': 9},
            {'name': 'Chryses Vohu Manah', 'amount': 13},
            {'name': 'Nuadha Lycus', 'amount': 19}
        ];

only in reality this array "itemsLis" has about 2000 (2 yew) object elements, and when typing letters, there is a rather large delay :(
Can someone tell me how to change my filter so that it works without brakes.
Or maybe there are already good ready-made autocompete solutions which work with a large array of data
PS
This is part of my PhoneGap application.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy, 2015-07-16
@Scorpiored88

The fact is that this code is from my PhoneGap application. The program will request data from the server only once (or when updating the database), after which it writes them to a local file, and at each next start of the program, the "itemsLis" variable will be filled with this local file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question