Skip to content

Commit

Permalink
fix(module:pagination): fix pagination nzTotal 0 bug
Browse files Browse the repository at this point in the history
close #3648
  • Loading branch information
vthinkxie committed Jun 25, 2019
1 parent ecae334 commit d125478
Show file tree
Hide file tree
Showing 3 changed files with 7 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 @@ -7,7 +7,7 @@
</a>
<a *ngIf="type=='page'">{{ page }}</a>
</ng-template>
<ng-container *ngIf="nzHideOnSinglePage && (nzTotal > nzPageSize) || !nzHideOnSinglePage">
<ng-container *ngIf="(nzHideOnSinglePage && (nzTotal > nzPageSize)) || (nzTotal && !nzHideOnSinglePage)">
<ul class="ant-pagination"
[class.ant-table-pagination]="nzInTable"
[class.ant-pagination-simple]="nzSimple"
Expand Down
1 change: 1 addition & 0 deletions components/pagination/nz-pagination.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export class NzPaginationComponent implements OnInit, OnDestroy, OnChanges {
}
}
this.pages = pages;
console.log(this.pages);
this.cdr.markForCheck();
}

Expand Down
5 changes: 5 additions & 0 deletions components/pagination/nz-pagination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ describe('pagination', () => {
expect(testComponent.pageIndex).toBe(5);
});
});
it('should zero total hide all', () => {
testComponent.total = 0;
fixture.detectChanges();
expect(pagination.nativeElement.innerText).toEqual('');
});
it('should be hidden pagination when total is 0 and nzHideOnSinglePage is true', () => {
(testComponent as NzTestPaginationComponent).total = 0;
(testComponent as NzTestPaginationComponent).hideOnSinglePage = true;
Expand Down

0 comments on commit d125478

Please sign in to comment.