InfiniteScroll Ionic 2 | just take the same data (Solved)

I tried to create a mobile web app, using wp-rest-api-v2 … but I get the problem when you want to do the pagination (infinite scroll) .Data always repeat!
page 1.ts

xport class Page1 {
datas:any
pagination: number = 1;
constructor(
public navCtrl: NavController, private postService: Post){
postService.getPosts(this.pagination).then(data => {
console.log(data);
this.datas = data;
});
}
infiniteScroll(ev){
this.pagination=+1;
this.postService.getPosts(this.pagination)
.then(data => {
for(let i of data){
this.datas.push(i);
}
ev.complete();
});
};

provider

getPosts(pagination){
return this.http.get('http://127.0.0.1:85/wordpress/wp-json/wp/v2/posts/?per_page=10&page='+pagination)

.toPromise()
.then(data => data.json());

}

}

Pleasse Help Me

Hey! That is because you do not increment your pagination correctly.
instead of this.pagination=+1; do this.pagination += 1;

1 Like

Thank you ekhmoi:angel:
sekarang saya menggunakan kode
this.pagination++; pagination correctly

same like this code or not?
this.pagination+=1;pagination correctly

how to make if the data 0 … shiw message “no more data”