I'm trying to use the Angular-Material paginator. In the html, the pager appears after the list it applies to (where the user expects it).
Here is what it looks like (Data is just an array property from the component. That works fine. This is just about *ngFor
depending on the paginator)
<mat-list *ngIf="Data">
<mat-list-item *ngFor="let item of Data.slice(
dataPager.pageIndex * dataPager.pageSize,
(dataPager.pageIndex + 1) * dataPager.pageSize
)">
{{item.name}}
</mat-list-item>
<mat-paginator #dataPager [length]="Data.length"
[pageSize]="10"
[pageSizeOptions]="[5, 10, 25, 50, 100]">
</mat-paginator>
</mat-list>
However this gives me a big scary error
ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngForOf: '. Current value: 'ngForOf: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]'.
Strictly speaking, everything seems to work fine anyways but I don't want to get this error at all. I don't get this error if a put the paginator before the *ngFor
, but than the paginator isn't where I want it on the page. So how do I make sure the paginator component gets initialized before the *ngFor
component that is based on it, even though the paginator is further down the page?