Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/paginator/paginator.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="mat-paginator-container">
<div class="mat-paginator-page-size">
<div class="mat-paginator-page-size" *ngIf="!hidePageSize">
<div class="mat-paginator-page-size-label">
{{_intl.itemsPerPageLabel}}
</div>
Expand Down
15 changes: 15 additions & 0 deletions src/lib/paginator/paginator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,19 @@ describe('MatPaginator', () => {
expect(withStringPaginator.pageSize).toEqual(10);
expect(withStringPaginator.pageSizeOptions).toEqual([5, 10, 25, 100]);
});

it('should be able to hide the page size select', () => {
const element = fixture.nativeElement;

expect(element.querySelector('.mat-paginator-page-size'))
.toBeTruthy('Expected select to be rendered.');

fixture.componentInstance.hidePageSize = true;
fixture.detectChanges();

expect(element.querySelector('.mat-paginator-page-size'))
.toBeNull('Expected select to be removed.');
});
});

function getPreviousButton(fixture: ComponentFixture<any>) {
Expand All @@ -279,6 +292,7 @@ function getNextButton(fixture: ComponentFixture<any>) {
<mat-paginator [pageIndex]="pageIndex"
[pageSize]="pageSize"
[pageSizeOptions]="pageSizeOptions"
[hidePageSize]="hidePageSize"
[length]="length"
(page)="latestPageEvent = $event">
</mat-paginator>
Expand All @@ -288,6 +302,7 @@ class MatPaginatorApp {
pageIndex = 0;
pageSize = 10;
pageSizeOptions = [5, 10, 25, 100];
hidePageSize = false;
length = 100;

latestPageEvent: PageEvent | null;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/paginator/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export class MatPaginator implements OnInit, OnDestroy {
}
private _pageSizeOptions: number[] = [];

/** Whether to hide the page size selection UI from the user. */
@Input() hidePageSize = false;

/** Event emitted when the paginator changes the page size or page index. */
@Output() page = new EventEmitter<PageEvent>();

Expand Down