I have a simple <input>
search filter set up for a list of itemnames in AngularJS
.
My list looks like this:
var uniqueLists = {
category1: ['item1', 'item2', 'item3' ... 'item180' ], // Real list contains ~180 items
category2: ['itemA', 'itemB', 'itemC' ... 'itemZZZ' ], // Real list contains ~1080 items
category3: ['otheritem1', 'otheritem2', 'otheritem3' ] // Real list contains 6 items
}
I iterate through this list in Angular and print out the results in a <ul>
for each category.
<div ng-repeat="(key,val) in uniqueLists">
<form ng-model="uniqueLists[index][0]">
<input ng-model="searchFilter" type="text" />
<ul>
<li ng-repeat="value in val | filter: searchFilter">
<label>
<input type="checkbox" ng-model="selectedData[key][value]" />
{{value}}
</label>
</li>
</ul>
</form>
</div>
For clarity, selectedData looks like this:
var selectedData = {category1: [item1:true], category2: [], category3: []); // if 'item1's checkbox is checked.
This list is working just fine, although the filter
is quite laggy, even on my quite-fast computer. Typing a letter into the input takes 1-2 seconds for the list to update.
I'm aware that this is likely because I'm filtering through around about 1000 items at a time, but I haven't seen any discussion of this elsewhere.
Is there any way to get better performance out of the filter?