Reputation: 135
I am using ng-repeat to render a complex set of data in the UI. After receiving the data, I need to filter the data based on some checkboxes, sliders etc. Right now I will have 6 custom filters, based on time, price, and some checkboxes. I am using them like following
ng:repeat="response in searchResponse|filter:filter1(response)|filter:filter2(response)|filter:filter3(response)|filter:filter4(response)|filter:filter5(response)|filter:filter6(response)|limitTo:totalDisplayed
This works fine but I think this is a very expensive way of applying filters. I have noticed a considerable lag in performance in rendering after this. Is there a better way to handle filters here ? Considering the fact that I may have more such filters in future.
Please suggest. Thanks !
Upvotes: 1
Views: 193
Reputation: 2996
Instead of chaining filters, why not something like:
ng:repeat="response in searchResponse|filter:genericFilter(response, filterConditions)|limitTo:totalDisplayed
What you're doing is like chaining filters one after another, and that may not necessarily be needed – one filter that selects out the results based on filterConditions
Upvotes: 1