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 6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { Injectable } from '@angular/core' ;
9
+ import { Injectable , SkipSelf , Optional } from '@angular/core' ;
10
10
import { Subject } from 'rxjs/Subject' ;
11
11
import { SortDirection } from './sort-direction' ;
12
12
@@ -32,3 +32,16 @@ export class MatSortHeaderIntl {
32
32
return `Sorted by ${ id } ${ direction == 'asc' ? 'ascending' : 'descending' } ` ;
33
33
}
34
34
}
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 9
9
import { NgModule } from '@angular/core' ;
10
10
import { MatSortHeader } from './sort-header' ;
11
11
import { MatSort } from './sort' ;
12
- import { MatSortHeaderIntl } from './sort-header-intl' ;
12
+ import { MAT_SORT_HEADER_INTL_PROVIDER } from './sort-header-intl' ;
13
13
import { CommonModule } from '@angular/common' ;
14
14
15
15
16
16
@NgModule ( {
17
17
imports : [ CommonModule ] ,
18
18
exports : [ MatSort , MatSortHeader ] ,
19
19
declarations : [ MatSort , MatSortHeader ] ,
20
- providers : [ MatSortHeaderIntl ]
20
+ providers : [ MAT_SORT_HEADER_INTL_PROVIDER ]
21
21
} )
22
22
export class MatSortModule { }
You can’t perform that action at this time.
0 commit comments