Skip to content

Commit 0ccedce

Browse files
committed
sync and fix test
1 parent 1e095ed commit 0ccedce

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/lib/radio/radio.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
9191
/** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
9292
private _labelPosition: 'before' | 'after' = 'after';
9393

94+
/** Whether the radio group is disabled. */
95+
private _disabled: boolean = false;
96+
9497
/** The method to be called in order to update ngModel */
9598
_controlValueAccessorChangeFn: (value: any) => void = (value) => {};
9699

@@ -176,7 +179,20 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
176179
this._checkSelectedRadioButton();
177180
}
178181

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+
}
180196

181197
/**
182198
* Initialize properties once content children are available.
@@ -266,6 +282,7 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase
266282
*/
267283
setDisabledState(isDisabled: boolean) {
268284
this.disabled = isDisabled;
285+
this._change.markForCheck();
269286
}
270287
}
271288

@@ -384,9 +401,10 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy {
384401
get disabled(): boolean {
385402
return this._disabled || (this.radioGroup != null && this.radioGroup.disabled);
386403
}
387-
388404
set disabled(value: boolean) {
389405
this._disabled = coerceBooleanProperty(value);
406+
// Update rippleDisabled
407+
this._changeDetector.markForCheck();
390408
}
391409

392410
/**
@@ -428,6 +446,7 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy {
428446
constructor(@Optional() radioGroup: MdRadioGroup,
429447
private _elementRef: ElementRef,
430448
private _renderer: Renderer2,
449+
private _changeDetector: ChangeDetectorRef,
431450
private _focusOriginMonitor: FocusOriginMonitor,
432451
private _radioDispatcher: UniqueSelectionDispatcher) {
433452
// Assertions. Ideally these should be stripped out by the compiler.
@@ -448,6 +467,8 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy {
448467
}
449468

450469
_groupValueChanged() {
470+
//When group value changes, the button will not be notified. Use `markForCheck` to explicit
471+
//update radio button's status
451472
this._changeDetector.markForCheck();
452473
}
453474

0 commit comments

Comments
 (0)