I am using a MatPaginator with a customized length. The issue is that the customized length works just after initial loading. But after that, when I execute other API request using a search input field, and get a new result, the paginator shows the default length of the dataSource again. How can I keep the my defined customized length over the whole process?
The value if the customized length should be used just if it's not 0, otherwise the default dataSource length should be passed/used
TS:
@ViewChild('usersPaginator')
public set usersPaginator(mp: MatPaginator) {
if (this.dataSourceUsers) {
this.dataSourceUsers.paginator = mp;
}
}
HTML:
<mat-paginator #usersPaginator [length]="usersService.customizedLength()" [pageSizeOptions]="[5,10,15]" [showFirstLastButtons]="true" />
P.S. customizedLength() is a signal holding a result of calculation which I run in the service after getting the API response.