@@ -24,7 +24,10 @@ import {
2424 ViewEncapsulation ,
2525 Optional ,
2626 Inject ,
27- forwardRef
27+ forwardRef ,
28+ ChangeDetectionStrategy ,
29+ ChangeDetectorRef ,
30+ OnChanges ,
2831} from '@angular/core' ;
2932import { LEFT_ARROW , RIGHT_ARROW , ENTER , SPACE } from '@angular/cdk/keycodes' ;
3033import { CdkStepLabel } from './step-label' ;
@@ -60,9 +63,10 @@ export class StepperSelectionEvent {
6063 moduleId : module . id ,
6164 selector : 'cdk-step' ,
6265 templateUrl : 'step.html' ,
63- encapsulation : ViewEncapsulation . None
66+ encapsulation : ViewEncapsulation . None ,
67+ changeDetection : ChangeDetectionStrategy . OnPush ,
6468} )
65- export class CdkStep {
69+ export class CdkStep implements OnChanges {
6670 /** Template for step label if it exists. */
6771 @ContentChild ( CdkStepLabel ) stepLabel : CdkStepLabel ;
6872
@@ -72,12 +76,11 @@ export class CdkStep {
7276 /** The top level abstract control of the step. */
7377 @Input ( ) stepControl : AbstractControl ;
7478
75- /** Whether user has seen the expanded step content or not . */
79+ /** Whether user has seen the expanded step content or not. */
7680 interacted = false ;
7781
7882 /** Label of the step. */
79- @Input ( )
80- label : string ;
83+ @Input ( ) label : string ;
8184
8285 @Input ( )
8386 get editable ( ) { return this . _editable ; }
@@ -114,6 +117,12 @@ export class CdkStep {
114117 select ( ) : void {
115118 this . _stepper . selected = this ;
116119 }
120+
121+ ngOnChanges ( ) {
122+ // Since basically all inputs of the MdStep get proxied through the view down to the
123+ // underlying MdStepHeader, we have to make sure that change detection runs correctly.
124+ this . _stepper . _stateChanged ( ) ;
125+ }
117126}
118127
119128@Directive ( {
@@ -163,7 +172,9 @@ export class CdkStepper {
163172 /** Used to track unique ID for each stepper component. */
164173 _groupId : number ;
165174
166- constructor ( @Optional ( ) private _dir : Directionality ) {
175+ constructor (
176+ @Optional ( ) private _dir : Directionality ,
177+ private _changeDetectorRef : ChangeDetectorRef ) {
167178 this . _groupId = nextId ++ ;
168179 }
169180
@@ -187,6 +198,11 @@ export class CdkStepper {
187198 return `mat-step-content-${ this . _groupId } -${ i } ` ;
188199 }
189200
201+ /** Marks the component to be change detected. */
202+ _stateChanged ( ) {
203+ this . _changeDetectorRef . markForCheck ( ) ;
204+ }
205+
190206 /** Returns position state of the step with the given index. */
191207 _getAnimationDirection ( index : number ) : StepContentPositionState {
192208 const position = index - this . _selectedIndex ;
@@ -217,6 +233,7 @@ export class CdkStepper {
217233 previouslySelectedStep : stepsArray [ this . _selectedIndex ] ,
218234 } ) ;
219235 this . _selectedIndex = newIndex ;
236+ this . _stateChanged ( ) ;
220237 }
221238
222239 _onKeydown ( event : KeyboardEvent ) {
0 commit comments