Попробуйте:
Component.html:
<div style="display:flex">
<mat-card class="mt-2" *ngFor="let item of tempList">
<mat-card-header>
<mat-card-title> {{item.title}} </mat-card-title>
</mat-card-header>
</mat-card>
</div>
<mat-paginator [length]="list.length" [pageSize]="pageSize" [pageSizeOptions]="[5, 10, 25, 100]" (page)="onPageChange($event)">
</mat-paginator>
Component.ts:
import { Component } from '@angular/core';
@Component({
selector: 'paginator-overview-example',
templateUrl: 'paginator-overview-example.html',
styleUrls: ['paginator-overview-example.css'],
})
export class PaginatorOverviewExample {
list = [];
pageSize=5;
tempList=[];
ngOnInit() {
// get your list from api
for (let i = 1; i < 1000; i++) {
this.list.push({
title:"item " + i
});
}
this.tempList=this.list.slice(0,this.pageSize);
}
onPageChange(e) {
this.tempList = this.list.slice(e.pageIndex * e.pageSize,(e.pageIndex + 1) *e.pageSize);
}
}
Надеюсь, это поможет вам.