I am trying to add an infinite scroll with ngx-infinite-scroll in my Angular 4 project.
The array data has about 800 posts which are from API.
<first, save your original array like this
this.dataService.getPosts().subscribe((response)=>{
this.originalPosts = response;
this.posts = response.slice(0,20);
});
onScrollDown(){
if(this.posts.length < this.originalPosts.length){
let len = this.posts.length;
for(i = len; i <= len+20; i++){
this.posts.push(this.originalPosts[i]);
}
}
}
just push it on the same array you don't need to append it to the table directly, angular will manage itself, its too easy when using angular.