I am retrieving a list of questions from an API with pagination. I have a button that triggers a function to load the next page of questions. Instead of replacing the previous page, I want to append the new questions below the existing ones. Here is my current code:
home.html:
<div *ngFor="let question of this.questions?.data">
<ion-item class="questions_div" (click)="goToConsult(question.id);">
<p text-wrap>{{question.title}}</p>
<span>{{question.created_at | jalali}}</span>
</ion-item>
</div>
Currently, when I load the second page, it replaces the first page. I want the new questions to be added below the existing ones.
home.ts=>
loadMore(currentPage){
this.nextPage = ++this.currentPage;
this.showLatestQuestions(this.nextPage);}
showLatestQuestions(currentPage){
this.questionsProvider.getLatestQuestions(currentPage)
.then(data => {
this.questions = data;
this.currentPage = this.questions.current_page;
return this.currentPage;
})
.catch(error => alert(error)); }