@@ -22,6 +22,7 @@ import {
2222 forwardRef ,
2323 Inject ,
2424 Input ,
25+ OnChanges ,
2526 OnDestroy ,
2627 OnInit ,
2728 Output ,
@@ -96,6 +97,7 @@ export class MatListOption extends _MatListOptionMixinBase
9697
9798 private _selected = false ;
9899 private _disabled = false ;
100+ private _parentStateSubscription : Subscription ;
99101
100102 /** Whether the option has focus. */
101103 _hasFocus : boolean = false ;
@@ -140,6 +142,9 @@ export class MatListOption extends _MatListOptionMixinBase
140142 /** @docs -private */
141143 @Inject ( forwardRef ( ( ) => MatSelectionList ) ) public selectionList : MatSelectionList ) {
142144 super ( ) ;
145+
146+ this . _parentStateSubscription = this . selectionList . _stateChanges
147+ . subscribe ( ( ) => this . _changeDetector . markForCheck ( ) ) ;
143148 }
144149
145150 ngOnInit ( ) {
@@ -172,6 +177,7 @@ export class MatListOption extends _MatListOptionMixinBase
172177 }
173178
174179 this . selectionList . _removeOptionFromList ( this ) ;
180+ this . _parentStateSubscription . unsubscribe ( ) ;
175181 }
176182
177183 /** Toggles the selection state of the option. */
@@ -265,11 +271,14 @@ export class MatListOption extends _MatListOptionMixinBase
265271 changeDetection : ChangeDetectionStrategy . OnPush
266272} )
267273export class MatSelectionList extends _MatSelectionListMixinBase implements FocusableOption ,
268- CanDisable , CanDisableRipple , AfterContentInit , ControlValueAccessor , OnDestroy {
274+ CanDisable , CanDisableRipple , AfterContentInit , ControlValueAccessor , OnDestroy , OnChanges {
269275
270276 /** The FocusKeyManager which handles focus. */
271277 _keyManager : FocusKeyManager < MatListOption > ;
272278
279+ /** Used to notify any child components listening to state changes. */
280+ readonly _stateChanges = new EventEmitter < void > ( ) ;
281+
273282 /** The option components contained within this selection-list. */
274283 @ContentChildren ( MatListOption ) options : QueryList < MatListOption > ;
275284
@@ -296,6 +305,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
296305 /** Used for storing the values that were assigned before the options were initialized. */
297306 private _tempValues : string [ ] | null ;
298307
308+ /** Subscription to sync value changes in the SelectionModel back to the SelectionList. */
299309 private _modelChanges = Subscription . EMPTY ;
300310
301311 /** View to model callback that should be called if the list or its options lost focus. */
@@ -335,6 +345,10 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
335345 } ) ;
336346 }
337347
348+ ngOnChanges ( ) {
349+ this . _stateChanges . next ( ) ;
350+ }
351+
338352 ngOnDestroy ( ) {
339353 this . _modelChanges . unsubscribe ( ) ;
340354 }
0 commit comments