Answer the question
In order to leave comments, you need to log in
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>
$scope.stationSearch = {}'';
$scope.setStation = function(bnn){
$scope.stationSearch.val = '';
$scope.stationSearch.val = bnn;
};
$http.get('http://serverUrl/')
.success(function(data){
$scope.itemsList = data;
})
$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}
];
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question