Place <ion-infinite-scroll> after the list, load the next page in its ionInfinite handler, then call complete() on the event target, and disable it when there is no more data.
<ion-content>
<ion-list>
<ion-item *ngFor="let item of items">{{ item }}</ion-item>
</ion-list>
<ion-infinite-scroll threshold="100px" (ionInfinite)="loadMore($event)">
<ion-infinite-scroll-content loadingText="Loading more…"></ion-infinite-scroll-content>
</ion-infinite-scroll>
</ion-content>import { InfiniteScrollCustomEvent } from '@ionic/angular';
items: string[] = [];
page = 0;
async loadMore(event: InfiniteScrollCustomEvent) {
const next = await this.api.getPage(++this.page); // your data source
this.items.push(...next);
event.target.complete();
if (next.length === 0) {
event.target.disabled = true; // nothing left to load
}
}Always call complete(), even after an error, or the control will not fire again. Load the first page yourself, since infinite scroll only triggers when the user scrolls near the end.
