HI all :)…
I’m trying to implement infinit-scroll with a request I made from a service.
The current example dousnt show where the data is coming from…
I’m not sure how to load the data to the list after getting it
Code:
public products: any;
constructor(private code4sa: Code4Sa) {
this.getProducts();
}
getProducts() {
this.code4sa.load()
.then(data => {
this.products = data;
});
}
doInfinite(infiniteScroll) {
console.log('Begin async operation');
setTimeout(() => {
for (var i = 0; i < 30; i++) {
this.products.push(this.products.length);
}
console.log('Async operation has ended');
infiniteScroll.complete();
}, 500);
}
and in my view
<ion-list>
<ion-item *ngFor="#product of products">
{{product.name}}
</ion-item>
</ion-list>
<ion-infinite-scroll (infinite)="doInfinite($event)" threshold="100px">
<ion-infinite-scroll-content loadingSpinner="bubbles"
loadingText="Loading more data...">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
Currently its only displaying blank tabs at the end. In other words I do not know how to only display 30 items fromthis.getProducts();
then keep on displaying more when you scroll down.