@@ -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' ;
@@ -63,8 +66,9 @@ export class StepperSelectionEvent {
6366 templateUrl : 'step.html' ,
6467 encapsulation : ViewEncapsulation . None ,
6568 preserveWhitespaces : false ,
69+ changeDetection : ChangeDetectionStrategy . OnPush ,
6670} )
67- export class CdkStep {
71+ export class CdkStep implements OnChanges {
6872 /** Template for step label if it exists. */
6973 @ContentChild ( CdkStepLabel ) stepLabel : CdkStepLabel ;
7074
@@ -74,12 +78,11 @@ export class CdkStep {
7478 /** The top level abstract control of the step. */
7579 @Input ( ) stepControl : AbstractControl ;
7680
77- /** Whether user has seen the expanded step content or not . */
81+ /** Whether user has seen the expanded step content or not. */
7882 interacted = false ;
7983
8084 /** Label of the step. */
81- @Input ( )
82- label : string ;
85+ @Input ( ) label : string ;
8386
8487 @Input ( )
8588 get editable ( ) { return this . _editable ; }
@@ -116,6 +119,12 @@ export class CdkStep {
116119 select ( ) : void {
117120 this . _stepper . selected = this ;
118121 }
122+
123+ ngOnChanges ( ) {
124+ // Since basically all inputs of the MdStep get proxied through the view down to the
125+ // underlying MdStepHeader, we have to make sure that change detection runs correctly.
126+ this . _stepper . _stateChanged ( ) ;
127+ }
119128}
120129
121130@Directive ( {
@@ -166,7 +175,9 @@ export class CdkStepper {
166175 /** Used to track unique ID for each stepper component. */
167176 _groupId : number ;
168177
169- constructor ( @Optional ( ) private _dir : Directionality ) {
178+ constructor (
179+ @Optional ( ) private _dir : Directionality ,
180+ private _changeDetectorRef : ChangeDetectorRef ) {
170181 this . _groupId = nextId ++ ;
171182 }
172183
@@ -190,6 +201,11 @@ export class CdkStepper {
190201 return `mat-step-content-${ this . _groupId } -${ i } ` ;
191202 }
192203
204+ /** Marks the component to be change detected. */
205+ _stateChanged ( ) {
206+ this . _changeDetectorRef . markForCheck ( ) ;
207+ }
208+
193209 /** Returns position state of the step with the given index. */
194210 _getAnimationDirection ( index : number ) : StepContentPositionState {
195211 const position = index - this . _selectedIndex ;
@@ -220,6 +236,7 @@ export class CdkStepper {
220236 previouslySelectedStep : stepsArray [ this . _selectedIndex ] ,
221237 } ) ;
222238 this . _selectedIndex = newIndex ;
239+ this . _stateChanged ( ) ;
223240 }
224241
225242 _onKeydown ( event : KeyboardEvent ) {
0 commit comments