我有一个对象,我想发送params。
所以ngOnInit工作,但我需要onScrollDown每次滚动时添加到我的参数pageNumber + 1
。
我怎样才能做到这一点 ?
questionListParams = {
pageNumber: 1,
pageSize: 10,
};
ngOnInit() {
this.questionsHttpRequests.getQuestions(this.questionListParams).subscribe((response) => {
this.listOfQuestions = response;
});
}
onScrollDown() {
this.questionsHttpRequests.getQuestions((this.questionListParams)).subscribe((response) => {
this.listOfQuestions.push(...response);
});
}
您可以在拨打电话之前或之后递增。
onScrollDown() {
// Before
this.questionListParams.pageNumber++;
this.questionsHttpRequests.getQuestions((this.questionListParams)).subscribe((response) => {
this.listOfQuestions.push(...response);
});
// Or after
this.questionListParams.pageNumber++;
}