Skip to content

Commit b833556

Browse files
committed
fix(paginator): Display '1 of 1' when there are no records to show
1 parent 0d89ee9 commit b833556

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

projects/igniteui-angular/src/lib/paginator/pager.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
paginator.resourceStrings.igx_paginator_pager_text
3030
}}&nbsp;</span
3131
>
32-
<span>{{ paginator.totalPages }}</span>
32+
<span>{{ paginator.totalPages || 1 }}</span>
3333
</div>
3434
<button
3535
[title]="paginator.resourceStrings.igx_paginator_next_page_button_text"

projects/igniteui-angular/src/lib/paginator/paginator.component.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,24 @@ describe('IgxPaginator with default settings', () => {
217217
expect(paginator.perPageChange.emit).toHaveBeenCalledTimes(1);
218218
});
219219

220+
it('should display "1 of 1" when there are no records to show', () => {
221+
const fix = TestBed.createComponent(DefaultPaginatorComponent);
222+
fix.detectChanges();
223+
224+
const totalPages = fix.debugElement.query(By.css('.igx-page-nav__text > span:last-child')).nativeElement;
225+
const paginator = fix.componentInstance.paginator;
226+
227+
paginator.totalRecords = null;
228+
fix.detectChanges();
229+
230+
expect(totalPages.innerText).toBe('1');
231+
232+
paginator.totalRecords = 0;
233+
fix.detectChanges();
234+
235+
expect(totalPages.innerText).toBe('1');
236+
});
237+
220238
});
221239

222240
describe('IgxPaginator with custom settings', () => {

0 commit comments

Comments
 (0)