@@ -24,6 +24,8 @@ import {
24
24
ViewEncapsulation ,
25
25
forwardRef ,
26
26
AfterViewInit ,
27
+ ChangeDetectionStrategy ,
28
+ ChangeDetectorRef ,
27
29
} from '@angular/core' ;
28
30
import { NG_VALUE_ACCESSOR , ControlValueAccessor } from '@angular/forms' ;
29
31
import { UniqueSelectionDispatcher , coerceBooleanProperty , FocusOriginMonitor } from '../core' ;
@@ -268,6 +270,7 @@ export class MdButtonToggleGroupMultiple extends _MdButtonToggleGroupMixinBase
268
270
templateUrl : 'button-toggle.html' ,
269
271
styleUrls : [ 'button-toggle.css' ] ,
270
272
encapsulation : ViewEncapsulation . None ,
273
+ changeDetection : ChangeDetectionStrategy . OnPush ,
271
274
host : {
272
275
'[class.mat-button-toggle-standalone]' : '!buttonToggleGroup && !buttonToggleGroupMultiple' ,
273
276
'class' : 'mat-button-toggle'
@@ -322,11 +325,10 @@ export class MdButtonToggle implements OnInit, OnDestroy {
322
325
}
323
326
324
327
set checked ( newCheckedState : boolean ) {
325
- if ( this . _isSingleSelector ) {
326
- if ( newCheckedState ) {
327
- // Notify all button toggles with the same name (in the same group) to un-check.
328
- this . _buttonToggleDispatcher . notify ( this . id , this . name ) ;
329
- }
328
+ if ( this . _isSingleSelector && newCheckedState ) {
329
+ // Notify all button toggles with the same name (in the same group) to un-check.
330
+ this . _buttonToggleDispatcher . notify ( this . id , this . name ) ;
331
+ this . _changeDetectorRef . markForCheck ( ) ;
330
332
}
331
333
332
334
this . _checked = newCheckedState ;
@@ -368,19 +370,21 @@ export class MdButtonToggle implements OnInit, OnDestroy {
368
370
369
371
constructor ( @Optional ( ) toggleGroup : MdButtonToggleGroup ,
370
372
@Optional ( ) toggleGroupMultiple : MdButtonToggleGroupMultiple ,
373
+ private _changeDetectorRef : ChangeDetectorRef ,
371
374
private _buttonToggleDispatcher : UniqueSelectionDispatcher ,
372
375
private _renderer : Renderer2 ,
373
376
private _elementRef : ElementRef ,
374
377
private _focusOriginMonitor : FocusOriginMonitor ) {
375
- this . buttonToggleGroup = toggleGroup ;
376
378
379
+ this . buttonToggleGroup = toggleGroup ;
377
380
this . buttonToggleGroupMultiple = toggleGroupMultiple ;
378
381
379
382
if ( this . buttonToggleGroup ) {
380
383
this . _removeUniqueSelectionListener =
381
384
_buttonToggleDispatcher . listen ( ( id : string , name : string ) => {
382
385
if ( id != this . id && name == this . name ) {
383
386
this . checked = false ;
387
+ this . _changeDetectorRef . markForCheck ( ) ;
384
388
}
385
389
} ) ;
386
390
0 commit comments