Angular 4 With Ngx Infinite Scroll
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. Initially, I want to display 20 po
Solution 1:
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.
Post a Comment for "Angular 4 With Ngx Infinite Scroll"