File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { Injectable } from '@angular/core' ;
9+ import { Injectable , SkipSelf , Optional } from '@angular/core' ;
1010import { Subject } from 'rxjs/Subject' ;
1111import { SortDirection } from './sort-direction' ;
1212
@@ -32,3 +32,16 @@ export class MatSortHeaderIntl {
3232 return `Sorted by ${ id } ${ direction == 'asc' ? 'ascending' : 'descending' } ` ;
3333 }
3434}
35+ /** @docs -private */
36+ export function MAT_SORT_HEADER_INTL_PROVIDER_FACTORY ( parentIntl : MatSortHeaderIntl ) {
37+ return parentIntl || new MatSortHeaderIntl ( ) ;
38+ }
39+
40+ /** @docs -private */
41+ export const MAT_SORT_HEADER_INTL_PROVIDER = {
42+ // If there is already an MatSortHeaderIntl available, use that. Otherwise, provide a new one.
43+ provide : MatSortHeaderIntl ,
44+ deps : [ [ new Optional ( ) , new SkipSelf ( ) , MatSortHeaderIntl ] ] ,
45+ useFactory : MAT_SORT_HEADER_INTL_PROVIDER_FACTORY
46+ } ;
47+
Original file line number Diff line number Diff line change 99import { NgModule } from '@angular/core' ;
1010import { MatSortHeader } from './sort-header' ;
1111import { MatSort } from './sort' ;
12- import { MatSortHeaderIntl } from './sort-header-intl' ;
12+ import { MAT_SORT_HEADER_INTL_PROVIDER } from './sort-header-intl' ;
1313import { CommonModule } from '@angular/common' ;
1414
1515
1616@NgModule ( {
1717 imports : [ CommonModule ] ,
1818 exports : [ MatSort , MatSortHeader ] ,
1919 declarations : [ MatSort , MatSortHeader ] ,
20- providers : [ MatSortHeaderIntl ]
20+ providers : [ MAT_SORT_HEADER_INTL_PROVIDER ]
2121} )
2222export class MatSortModule { }
You can’t perform that action at this time.
0 commit comments