@@ -28,12 +28,14 @@ import {
2828 ChangeDetectionStrategy ,
2929 ChangeDetectorRef ,
3030 OnChanges ,
31+ OnDestroy
3132} from '@angular/core' ;
3233import { LEFT_ARROW , RIGHT_ARROW , ENTER , SPACE } from '@angular/cdk/keycodes' ;
3334import { CdkStepLabel } from './step-label' ;
3435import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
3536import { AbstractControl } from '@angular/forms' ;
3637import { Direction , Directionality } from '@angular/cdk/bidi' ;
38+ import { Subject } from 'rxjs/Subject' ;
3739
3840/** Used to generate unique ID for each stepper component. */
3941let nextId = 0 ;
@@ -132,7 +134,10 @@ export class CdkStep implements OnChanges {
132134 selector : '[cdkStepper]' ,
133135 exportAs : 'cdkStepper' ,
134136} )
135- export class CdkStepper {
137+ export class CdkStepper implements OnDestroy {
138+ /** Emits when the component is destroyed. */
139+ protected _destroyed = new Subject < void > ( ) ;
140+
136141 /** The list of step components that the stepper is holding. */
137142 @ContentChildren ( CdkStep ) _steps : QueryList < CdkStep > ;
138143
@@ -186,6 +191,11 @@ export class CdkStepper {
186191 this . _groupId = nextId ++ ;
187192 }
188193
194+ ngOnDestroy ( ) {
195+ this . _destroyed . next ( ) ;
196+ this . _destroyed . complete ( ) ;
197+ }
198+
189199 /** Selects and focuses the next step in list. */
190200 next ( ) : void {
191201 this . selectedIndex = Math . min ( this . _selectedIndex + 1 , this . _steps . length - 1 ) ;
0 commit comments