hi, when i use infinite-scroll in ion-tab doInfinite()
function not called after scrolling page.
i try all Lifecycle events
but still dosent work.
how can i fixed it?
ionic version : 3.9.2
ts file:
export class PageName {
transactions: any = [];
constructor(navParams: NavParams) {
this.userInfo = new User();
if (navParams.get('kind') !== undefined) {
this.kind = navParams.get('kind');
this.loadData();
}
}
loadData() {
this.offset = 0;
this.global.presentLoading({ content: 'Please wait...' });
this.global.httpPostObservable('pageName', { limit: this.limit, offset: this.offset, kind: this.kind }, this.userInfo.token).subscribe((data) => {
this.transactions = data.result.transactions;
this.global.dismissLoading();
}, (error) => {
this.global.showError(error).then(()=>{
this.global.dismissLoading();
});
});
}
doInfinite(infiniteScroll) {
this.offset = this.offset + this.limit;
if (!this.isFinish) {
setTimeout(() => {
this.global.presentLoading({ content: 'Please wait...' });
this.global.httpPostObservable('pageName/loadmore', { limit: this.limit, offset: this.offset, kind: this.kind }, this.userInfo.token).subscribe((data) => {
this.transactions = this.transactions.concat(data.result);
if (data.result.length < this.limit) {
this.isFinish = true;
}
}, (error) => {
this.global.showError(error).then(()=>{
this.global.dismissLoading();
});
});
infiniteScroll.complete();
}, 500);
} else {
infiniteScroll.complete();
}
}
}
html page:
<ion-list class="MenuTable" no-lines>
<ion-item *ngFor="let item of transactions;" class="trans">
<ion-row align-items-center justify-content-between>
<ion-col>
#{{item.id}}
</ion-col>
</ion-row>
</ion-item>
</ion-list>
<ion-infinite-scroll (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>