Skip to content

Commit 675aa66

Browse files
crisbetojosephperrott
authored andcommitted
fix(stepper): intl provider not being picked up in lazy-loaded modules (#12934)
1 parent 861642c commit 675aa66

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/lib/stepper/stepper-intl.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Injectable} from '@angular/core';
9+
import {Injectable, Optional, SkipSelf} from '@angular/core';
1010
import {Subject} from 'rxjs';
1111

1212

@@ -22,3 +22,16 @@ export class MatStepperIntl {
2222
/** Label that is rendered below optional steps. */
2323
optionalLabel: string = 'Optional';
2424
}
25+
26+
27+
/** @docs-private */
28+
export function MAT_STEPPER_INTL_PROVIDER_FACTORY(parentIntl: MatStepperIntl) {
29+
return parentIntl || new MatStepperIntl();
30+
}
31+
32+
/** @docs-private */
33+
export const MAT_STEPPER_INTL_PROVIDER = {
34+
provide: MatStepperIntl,
35+
deps: [[new Optional(), new SkipSelf(), MatStepperIntl]],
36+
useFactory: MAT_STEPPER_INTL_PROVIDER_FACTORY
37+
};

src/lib/stepper/stepper-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {MatStepLabel} from './step-label';
1818
import {MatHorizontalStepper, MatStep, MatStepper, MatVerticalStepper} from './stepper';
1919
import {MatStepperNext, MatStepperPrevious} from './stepper-button';
2020
import {MatStepperIcon} from './stepper-icon';
21-
import {MatStepperIntl} from './stepper-intl';
21+
import {MAT_STEPPER_INTL_PROVIDER} from './stepper-intl';
2222

2323

2424
@NgModule({
@@ -54,6 +54,6 @@ import {MatStepperIntl} from './stepper-intl';
5454
MatStepHeader,
5555
MatStepperIcon,
5656
],
57-
providers: [MatStepperIntl, ErrorStateMatcher],
57+
providers: [MAT_STEPPER_INTL_PROVIDER, ErrorStateMatcher],
5858
})
5959
export class MatStepperModule {}

0 commit comments

Comments
 (0)