@@ -91,6 +91,9 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
91
91
/** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
92
92
private _labelPosition : 'before' | 'after' = 'after' ;
93
93
94
+ /** Whether the radio group is disabled. */
95
+ private _disabled : boolean = false ;
96
+
94
97
/** The method to be called in order to update ngModel */
95
98
_controlValueAccessorChangeFn : ( value : any ) => void = ( value ) => { } ;
96
99
@@ -176,7 +179,20 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
176
179
this . _checkSelectedRadioButton ( ) ;
177
180
}
178
181
179
- constructor ( private _change : ChangeDetectorRef ) { }
182
+ /** Whether the radio group is diabled */
183
+ @Input ( )
184
+ get disabled ( ) { return this . _disabled ; }
185
+ set disabled ( value ) {
186
+ this . _disabled = value ;
187
+ if ( this . _radios ) {
188
+ // Update radios disabled state
189
+ this . _radios . forEach ( ( r ) => r . _groupValueChanged ( ) ) ;
190
+ }
191
+ }
192
+
193
+ constructor ( private _change : ChangeDetectorRef ) {
194
+ super ( ) ;
195
+ }
180
196
181
197
/**
182
198
* Initialize properties once content children are available.
@@ -266,6 +282,7 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
266
282
*/
267
283
setDisabledState ( isDisabled : boolean ) {
268
284
this . disabled = isDisabled ;
285
+ this . _change . markForCheck ( ) ;
269
286
}
270
287
}
271
288
@@ -384,9 +401,10 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy {
384
401
get disabled ( ) : boolean {
385
402
return this . _disabled || ( this . radioGroup != null && this . radioGroup . disabled ) ;
386
403
}
387
-
388
404
set disabled ( value : boolean ) {
389
405
this . _disabled = coerceBooleanProperty ( value ) ;
406
+ // Update rippleDisabled
407
+ this . _changeDetector . markForCheck ( ) ;
390
408
}
391
409
392
410
/**
@@ -428,6 +446,7 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy {
428
446
constructor ( @Optional ( ) radioGroup : MdRadioGroup ,
429
447
private _elementRef : ElementRef ,
430
448
private _renderer : Renderer2 ,
449
+ private _changeDetector : ChangeDetectorRef ,
431
450
private _focusOriginMonitor : FocusOriginMonitor ,
432
451
private _radioDispatcher : UniqueSelectionDispatcher ) {
433
452
// Assertions. Ideally these should be stripped out by the compiler.
@@ -448,6 +467,8 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy {
448
467
}
449
468
450
469
_groupValueChanged ( ) {
470
+ //When group value changes, the button will not be notified. Use `markForCheck` to explicit
471
+ //update radio button's status
451
472
this . _changeDetector . markForCheck ( ) ;
452
473
}
453
474
0 commit comments