4

Here are almost 2000 rows in the page. I use AngularJS filter to search some items which contains the typed strings. The problem is that efficiency is bad when typing one character into the input control. Do you guys have good ideas how to improve this filter? Here is the search code:

input box:

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

in the table's ng-repeat:

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

string filter:searchText is used to filter.

2

2 Answers 2

1

The bottleneck is likely adding and removing elements from the DOM. Avoid this by using css to hide elements. In stead of filtering the 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/

There is also the virtual ng-repeat plugin, it only adds the dom nodes which are going to be rendered for better performance

Sign up to request clarification or add additional context in comments.

1 Comment

yep, bottleneck is operate elements from DOC, I use ng-table instead of normal table, and pagination tech, efficiency is better than before.
0

I would also suggest to use the track by in the repeater. It will prevent unnecessary removal and reinsertion of elements and result in dramatic improvement in speed in some cases. Just make sure you are tracking by some unique property.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.