Optimize angularjs search filter

There are almost 2,000 lines per page. I use the AngularJS filter to search for some elements containing typed strings. The problem is that the efficiency of printing a single character in the input control is poor. Do you have any good ideas for improving this filter? Here is the search code:

entry field:

<input class="searchText ng-cloak" ng-model="searchText.ValueName" placeholder="Search Value" />

in the ng-repeat table:

<tr ng-repeat="registry in currentSettings | filter:searchText" ....

string is filter:searchTextused for filtering.

+4
source share
2 answers

The bottleneck probably adds and removes elements from DOM. Avoid this using css to hide elements. Instead of filtering ng-repeat, use ng-show:

<li ng-repeat="registry in currentSettings" ng-show="([registry] | filter:searchText).length > 0">

http://php.quicoto.com/use-ng-show-filtering-data-angularjs/

ng-repeat, dom,

+1

track by . . , - .

0

All Articles