Check/ Detect If Ionic View/ Page Reached Bottom Load Infinite Data

Like native Android apps, we sometimes need a view, where list items can be loaded after user reached the bottom of all loaded list items. This behavior is recommended if we have a long list to load and we don’t want the user to tap next every time to view next set of list items.

So we will do basically two things:

  1. How to Check If User Reached Bottom of Page/ View in Ionic App?

  2. How to Auto Load Infinite List of Records from API call in Single Ionic View?

 

Let’s begin…

Step 1) – In Our controller, we need to add an Ionic service $ionicScrollDelegate, then our controller will look something like this

 

Step 2) – Now we need to add some events in HTML which will call our Scroll function from the controller.

We will add on-scroll-complete=”checkScroll()” on our content html like below:

NOTE: I have used on-scroll-complete event Instead on on-scroll, becouse if we use on-scroll it will file on every pixel movement which can call api multiple times

 

Step 3) – In the controller, we will write logic to check if view reached the bottom.

In above function $scope.loadNextRecords() will call more records and push to existing list.

Sometimes this we may want to call loadNext imidiatly when user reaches middle of list, for that we can adust values of  currentTop and maxTop accordingly.

Let me know if you have any feedback issues of better suggestion in comments below 🙂

 

2 thoughts on “Check/ Detect If Ionic View/ Page Reached Bottom Load Infinite Data”

    1. Hello, please check if your view is having enough content to show scroll when loaded? and also verify if all steps are followed 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *