This is my Array data which is contains almost 100+ data
Items = [
title: "lorem ",
description: "lorem to an array?
How to implement infinite scrolling in table data? [closed]" },
title: "lorem ",
description: "lorem to an array?
How to implement infinite scrolling in table data? [closed]" },
title: "lorem ",
description: "lorem to an array?
How to implement infinite scrolling in table data? [closed]" },
title: "lorem ",
description: "lorem to an array?
How to implement infinite scrolling in table data? [closed]" },
title: "lorem ",
description: "lorem to an array?
How to implement infinite scrolling in table data? [closed]" },
]
I need to show 1st 5 of the data when user scroll it will show next 5 from this items data I am allready tried to follow the ionic documentation instruction where the code
Thanks, now I understand how infinity scroll work, I was actually trying to make some kinds of pagination but use documentation code without understanding but now I figure out the solution.
If you want to use infinite scroll , means show all the array data an start from beginning again ? then you need to use this.items.concat( dataService.Items ); and dont need to use any loop. but if you want to pagination like me, like show 1st 5 data when user scroll down it will show next 5 data. then use slice pipe in your *ngFor
my code
<ion-card id="list" *ngFor="let d of items | slice:0:slice; let i=index" text-wrap>
<ion-card-header>
{{d.title}}
</ion-card-header>
<ion-card-content [innerHTML]="d.description"></ion-card-content>
</ion-card>
look the *ngFor="let d of items | slice:0:slice; where i can use *ngFor="let d of items | slice:0:5; like that.
so i just store the 5 inside slice variable and i am increasing the value of this variable by triggering doInfinity() function, like