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
15 changes: 14 additions & 1 deletion src/lib/paginator/paginator-intl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Injectable} from '@angular/core';
import {Injectable, SkipSelf, Optional } from '@angular/core';
import {Subject} from 'rxjs/Subject';

/**
Expand Down Expand Up @@ -46,3 +46,16 @@ export class MatPaginatorIntl {
return `${startIndex + 1} - ${endIndex} of ${length}`;
}
}

/** @docs-private */
export function MAT_PAGINATOR_INTL_PROVIDER_FACTORY(parentIntl: MatPaginatorIntl) {
return parentIntl || new MatPaginatorIntl();
}

/** @docs-private */
export const MAT_PAGINATOR_INTL_PROVIDER = {
// If there is already an MatPaginatorIntl available, use that. Otherwise, provide a new one.
provide: MatPaginatorIntl,
deps: [[new Optional(), new SkipSelf(), MatPaginatorIntl]],
useFactory: MAT_PAGINATOR_INTL_PROVIDER_FACTORY
};
4 changes: 2 additions & 2 deletions src/lib/paginator/paginator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {MatButtonModule} from '@angular/material/button';
import {MatSelectModule} from '@angular/material/select';
import {MatTooltipModule} from '@angular/material/tooltip';
import {MatPaginator} from './paginator';
import {MatPaginatorIntl} from './paginator-intl';
import {MAT_PAGINATOR_INTL_PROVIDER} from './paginator-intl';


@NgModule({
Expand All @@ -24,6 +24,6 @@ import {MatPaginatorIntl} from './paginator-intl';
],
exports: [MatPaginator],
declarations: [MatPaginator],
providers: [MatPaginatorIntl],
providers: [MAT_PAGINATOR_INTL_PROVIDER],
})
export class MatPaginatorModule {}