Вы можете подписаться на пейджер следующим образом:
@Component({
selector: 'app-list',
templateUrl: './list.component.html',
],
})
export class ListComponent implements AfterViewInit {
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
data: MatTableDataSource<any>;
constructor(private http: HttpClient) {}
ngAfterViewInit(): void {
this.data = new MatTableDataSource([]);
this.data.paginator = this.paginator;
this.paginator.pageIndex = 0;
this.paginator.page.pipe(
startWith({}),
switchMap(() => {
const page = this.paginator.pageIndex + 1;
const itemsPerPage = this.paginator.pageSize;
return this.http.get(`api_url?page=${page}&itemsPerPage=${itemsPerPage}`);
}),
map((apiResponseData) => { return apiResponseData;}),
).subscribe((data) => {
this.data= new MatTableDataSource(data);
this.data._updateChangeSubscription();
});
}
}