Loading more data into our app can easily be done by using the ion-refresher component, and ion-infinite-scroll component. We'll look at the ion-refresher component first. To add this functionality, we'll modify our template and add the ion-refresher component between our ion-content and ion-list.
Inside of that, we'll create an ion-refresher content, and ten close it out. Now to create the functionality we'll bind to the event ionRefresh, and call a method doRefresh, passing in the event.
In our class, we'll create our doRefresh method and then call our service to get data from the random user API. With the data that comes back from our request, we'll take our original people array and use unshift plus a spread operator to add new data the front of our list.
To notify our refresher that the request is done, we'll complete our subscribe and in the done callback, we'll call event.complete, this will notify the refresher that it should be done refreshing. We'll save, and then be able to pull down in our app and load more data.
For infinite scroll, we more or less can follow the same pattern. We can go back to our template, and actually can take our ion-refresher component, copy and paste it below ion-list, and then rename it to ion-infinite-scroll. We'll also rename our event and method from ionRefresh and doRefresh to ionInfinite and doInfinite.
We'll go back to our class and duplicate our doRefresh method. We'll rename it to doInfinite, and this time instead of unshift, we'll use push instead. Now we'll be able to pull for more data and scroll to load more as well.