角材料分页器在检索数据后不允许按下后退按钮

问题描述 投票:0回答:1

使用材料分页器时出现问题。它正确地检索了数据,并且分页器数据正在正确更新,特别是pageIndex正在正确递增,但是项号没有更新,如下所示。我相信这是由于onChangedPage($ event)函数的缘故,因为当我删除它时,所有内容都可以正常运行,但是我的数据当然不会更新了。

screen shot of the item count

我想知道考虑到pageIndex是否正常工作的原因可能是什么,这是我的分页器代码。我的代码是动态的。

html:

<mat-paginator
      [length]="totalMessages"
      [pageSize]="messagesPerPage"
      [pageSizeOptions]="pageSizeOptions"
      (page)='onChangedPage($event)'
    ></mat-paginator>

TS:

onChangedPage(pageData: PageEvent) {
console.log(pageData);
this.currentPage = pageData.pageIndex + 1;
const endingIndex = this.messagesPerPage * this.currentPage;
const startingIndex = endingIndex - this.messagesPerPage;
this.isLoading = true;
console.log(endingIndex);
console.log(startingIndex);
this.Service
.getFunction(this..ticketNumber, startingIndex, endingIndex)
.subscribe(data => {
****taken out for security reasons
 }

摘要:本质上,我正在对Mongo DB文档中的嵌入式数组进行分页,并使用$ slice方法。我的后端逻辑很好,我可以正确检索所有内容,但是由于某种原因,分页器未更新要检索的项目的位置。任何帮助将不胜感激,谢谢!

javascript html angular angular-material angular-pagination
1个回答
0
投票

[如果有人遇到这种类型的问题。我发现问题是因为在调用后端数据时使用了加载微调器。这改变了视图并重置了页面数据。一旦我移除了微调器,它现在可以按预期工作。

© www.soinside.com 2019 - 2024. All rights reserved.