Skip to content

Commit

Permalink
fix(module:pagination): take minimum of page range and total (#2046)
Browse files Browse the repository at this point in the history
close #2036
  • Loading branch information
wen committed Aug 31, 2018
1 parent 2e8e63d commit 30bccd1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/pagination/nz-pagination.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<span class="ant-pagination-total-text" *ngIf="nzShowTotal">
<ng-template
[ngTemplateOutlet]="nzShowTotal"
[ngTemplateOutletContext]="{ $implicit: nzTotal,range:[(nzPageIndex-1)*nzPageSize+1,nzPageIndex*nzPageSize] }">
[ngTemplateOutletContext]="{ $implicit: nzTotal,range:[(nzPageIndex-1)*nzPageSize+1, min(nzPageIndex*nzPageSize, nzTotal)] }">
</ng-template>
</span>
<li
Expand Down
4 changes: 4 additions & 0 deletions components/pagination/nz-pagination.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ export class NzPaginationComponent implements OnInit, OnDestroy {
return this.nzPageIndex === this.firstIndex;
}

min(val1: number, val2: number): number {
return Math.min(val1, val2);
}

constructor(private i18n: NzI18nService) {
}

Expand Down
3 changes: 3 additions & 0 deletions components/pagination/nz-pagination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ describe('pagination', () => {
testComponent.pageIndex = 2;
fixture.detectChanges();
expect(paginationElement.firstElementChild.innerText).toBe('21-40 of 85 items');
testComponent.pageIndex = 5;
fixture.detectChanges();
expect(paginationElement.firstElementChild.innerText).toBe('81-85 of 85 items');
});
});

Expand Down

0 comments on commit 30bccd1

Please sign in to comment.