Reputation: 441
I use paginator in a search page. The paginator works fine untils the list are not empty.
<mat-paginator [length]="numbersTotalElements" [pageSize]="numberRowForPage" [pageIndex]="first" aria-label="Seleziona pagina" tabindex="0"> </mat-paginator>
I call a subscrive and I do this:
this.searchStudentService.search(this.fieldsSearch).pipe(takeUntil(this.subscrive$)).subscribe((result) => {
if (Utility.isNotNull(resultResponse)) {
this.listSearch = Utility.extractList(resultResponse);
this.numbersTotalElements= SortUtility.extract-...(resultResponse);
this.numberRowForPage= SortUtility.extract...(resultResponse);
this.first = 0;
console.log(this.numbersTotalElements)
console.log(this.numberRowForPage)
console.log(this.first)
this.dataSource = new MatTableDataSource<SearchResultStudent>(this.listSearch );
The problem is tha code work fine when I have (from my respose) some values but when the response is empty I read this:
the "elements for page is 50 but the console.log
it prints me all 0 so I don't know it take this 50.Anyne can help me?
Upvotes: 0
Views: 103
Reputation: 194
This 50 belongs to numberRowForPage
. It indicates the number of element that the page could show. If you return 0 elements, you should set numberRowForPage
also to 0.
Upvotes: 0