Answer the question
In order to leave comments, you need to log in
Is it possible to show multiple elements according to filters in a view in angularjs?
Thanks to orderBy and filter, data in ng-repeat can be sorted and filtered right in the view.
I need to do scrolling (loading of 10 elements) along with sorting and filtering.
Is it possible to do so in the view, so that ng-repeat would give an array of 100 elements that were filtered and sorted, but 10 elements were shown from the beginning, and when the button is clicked, another 10, on the next click another 10, etc. ?
If yes, how to do it?
If not, then I will do it through the controller.
Answer the question
In order to leave comments, you need to log in
It is possible if you create a filter that will display a certain number of elements (n) and apply it after the filter and orderBy filters. And when you click on the "Load more" button, increase the number n by 10. But this is a so-so solution. Knowledgeable people, like Sergey Protko , advise not to use filters with ng-repeat, but to prepare a filtered and sorted array at least in the controller. That's what I would do.
jsfiddle.net/api/post/library/pure
Not mine, attribution link fdietz.github.io/recipes-with-angular-js/common-us...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question