diff --git a/src/demo-app/paginator/paginator-demo.html b/src/demo-app/paginator/paginator-demo.html
index d75b72294f9..af3c21879c1 100644
--- a/src/demo-app/paginator/paginator-demo.html
+++ b/src/demo-app/paginator/paginator-demo.html
@@ -20,12 +20,14 @@
Hide page size
Show multiple page size options
Show first/last buttons
+ Disabled
@@ -32,9 +33,9 @@
(click)="firstPage()"
[attr.aria-label]="_intl.firstPageLabel"
[matTooltip]="_intl.firstPageLabel"
- [matTooltipDisabled]="!hasPreviousPage()"
+ [matTooltipDisabled]="_previousButtonsDisabled()"
[matTooltipPosition]="'above'"
- [disabled]="!hasPreviousPage()"
+ [disabled]="_previousButtonsDisabled()"
*ngIf="showFirstLastButtons">
`,
@@ -429,6 +453,7 @@ class MatPaginatorApp {
hidePageSize = false;
showFirstLastButtons = false;
length = 100;
+ disabled: boolean;
pageEvent = jasmine.createSpy('page event');
color: ThemePalette;
diff --git a/src/lib/paginator/paginator.ts b/src/lib/paginator/paginator.ts
index f6eefab4bce..0445dcd9f50 100644
--- a/src/lib/paginator/paginator.ts
+++ b/src/lib/paginator/paginator.ts
@@ -25,6 +25,9 @@ import {
HasInitializedCtor,
mixinInitialized,
ThemePalette,
+ mixinDisabled,
+ CanDisableCtor,
+ CanDisable,
} from '@angular/material/core';
/** The default page size if there is no page size and there are no provided page size options. */
@@ -54,8 +57,8 @@ export class PageEvent {
// Boilerplate for applying mixins to MatPaginator.
/** @docs-private */
export class MatPaginatorBase {}
-export const _MatPaginatorBase: HasInitializedCtor & typeof MatPaginatorBase =
- mixinInitialized(MatPaginatorBase);
+export const _MatPaginatorBase: CanDisableCtor & HasInitializedCtor & typeof MatPaginatorBase =
+ mixinDisabled(mixinInitialized(MatPaginatorBase));
/**
* Component to provide navigation between paged information. Displays the size of the current
@@ -68,13 +71,15 @@ export const _MatPaginatorBase: HasInitializedCtor & typeof MatPaginatorBase =
exportAs: 'matPaginator',
templateUrl: 'paginator.html',
styleUrls: ['paginator.css'],
+ inputs: ['disabled'],
host: {
'class': 'mat-paginator',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
-export class MatPaginator extends _MatPaginatorBase implements OnInit, OnDestroy, HasInitialized {
+export class MatPaginator extends _MatPaginatorBase implements OnInit, OnDestroy, CanDisable,
+ HasInitialized {
private _initialized: boolean;
private _intlChanges: Subscription;
@@ -234,6 +239,16 @@ export class MatPaginator extends _MatPaginatorBase implements OnInit, OnDestroy
this._emitPageEvent(previousPageIndex);
}
+ /** Checks whether the buttons for going forwards should be disabled. */
+ _nextButtonsDisabled() {
+ return this.disabled || !this.hasNextPage();
+ }
+
+ /** Checks whether the buttons for going backwards should be disabled. */
+ _previousButtonsDisabled() {
+ return this.disabled || !this.hasPreviousPage();
+ }
+
/**
* Updates the list of page size options to display to the user. Includes making sure that
* the page size is an option and that the list is sorted.