@@ -28,12 +28,14 @@ import {
28
28
ChangeDetectionStrategy ,
29
29
ChangeDetectorRef ,
30
30
OnChanges ,
31
+ OnDestroy
31
32
} from '@angular/core' ;
32
33
import { LEFT_ARROW , RIGHT_ARROW , ENTER , SPACE } from '@angular/cdk/keycodes' ;
33
34
import { CdkStepLabel } from './step-label' ;
34
35
import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
35
36
import { AbstractControl } from '@angular/forms' ;
36
37
import { Direction , Directionality } from '@angular/cdk/bidi' ;
38
+ import { Subject } from 'rxjs/Subject' ;
37
39
38
40
/** Used to generate unique ID for each stepper component. */
39
41
let nextId = 0 ;
@@ -132,7 +134,10 @@ export class CdkStep implements OnChanges {
132
134
selector : '[cdkStepper]' ,
133
135
exportAs : 'cdkStepper' ,
134
136
} )
135
- export class CdkStepper {
137
+ export class CdkStepper implements OnDestroy {
138
+ /** Emits when the component is destroyed. */
139
+ protected _destroyed = new Subject < void > ( ) ;
140
+
136
141
/** The list of step components that the stepper is holding. */
137
142
@ContentChildren ( CdkStep ) _steps : QueryList < CdkStep > ;
138
143
@@ -186,6 +191,11 @@ export class CdkStepper {
186
191
this . _groupId = nextId ++ ;
187
192
}
188
193
194
+ ngOnDestroy ( ) {
195
+ this . _destroyed . next ( ) ;
196
+ this . _destroyed . complete ( ) ;
197
+ }
198
+
189
199
/** Selects and focuses the next step in list. */
190
200
next ( ) : void {
191
201
this . selectedIndex = Math . min ( this . _selectedIndex + 1 , this . _steps . length - 1 ) ;
0 commit comments