We´re using infinite scroll and I can´t fix the problem that I have to scroll up and down. The load more function will start only when I scroll up and then down:
constructor(private itemService: ItemService) {
this.loadItemsForInfinite();
}
// Infinite scroll: load items
loadItemsForInfinite(event?) {
this.itemService.getItems(this.searchTerm)
.subscribe(res => {
this.items$ = this.items$.concat(res.items);
if (this.items$.length >= this.itemsCount$) {
this.items$.length = this.itemsCount$;
}
if (event) {
event.target.complete();
}
});
}
// Infinite scroll: more items after index 20
loadMoreItems(event) {
if (this.items$.length >= this.itemsCount$) {
event.target.disabled = true;
} else {
this.index = this.index + 20;
this.loadItemsForInfinite(event);
}
}
Any idea what could be my mistake?