1

I have a requirement where I query all the records and push it to array. And since I have about 2000 records to display, it takes more time. So I would like to implement infinite scroll. But I have filter feature along with this. So how can I show all records on scroll initially and show filtered records on scroll when search box contains search term? Pls help.

Thanks in Advance!

1
  • You really need to post some code. This isn't a place for people to write your code for you. If you haven't tried anything, you can check out sroze.github.io/ngInfiniteScroll Commented Jun 2, 2015 at 15:30

1 Answer 1

2

This is a slightly more complicated task since the built in angular filter requires all the elements to be in a local array before being able to filter. So you cannot use it, and must move the task of filtering to the server, for example using the sql %like% query.

You need to reuse both the array of records, and the pagination component. So there are 2 use cases:

  1. User is viewing unfiltered list
  2. User has entered a valid search query and is viewing a filtered list

When user is viewing the unfiltered list, you are querying the API endpoint ex:

server.com/api/records?page=page_number

When the user is viewing a filtered list, you are querying the API endpoint ex:

server.com/api/records?page=page_number&query=mysearchquery

So the entire task becomes:

  1. User is viewing unfiltered list
  2. User enters a search term in the search box

    • Use a debounce to check the input query for validation, ex: length > 4
  3. Front end clears entire list of records, and reset any pagination state

  4. Pagination now occuring on the filtered list

When a user clears the search box:

  1. Clear the list of filtered records and reset pagination state
  2. Begin paginating the unfiltered list once again

If you any specific questions about any part of the process, I'd be happy to update my answer.

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

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.