Skip to content

Commit 8b048a0

Browse files
committed
.
1 parent 0389dcb commit 8b048a0

File tree

1 file changed

+7
-46
lines changed

1 file changed

+7
-46
lines changed

src/lib/radio/radio.ts

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -128,31 +128,14 @@ export class MdRadioGroup implements AfterContentInit, ControlValueAccessor {
128128
}
129129

130130
/** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
131-
_labelPosition: 'before' | 'after' = 'after';
132-
@Input()
133-
get labelPosition(): 'before' | 'after' {
134-
return this._labelPosition;
135-
}
136-
set labelPosition(v: 'before' | 'after') {
137-
this._labelPosition = v
138-
if (this._radios) {
139-
this._radios.forEach((radio) => {
140-
radio.labelPosition = this._labelPosition;
141-
});
142-
}
143-
}
131+
@Input() labelPosition: 'before' | 'after' = 'after';
144132

145133
/** Whether the radio button is disabled. */
146134
@Input()
147135
get disabled(): boolean { return this._disabled; }
148136
set disabled(value) {
149137
// The presence of *any* disabled value makes the component disabled, *except* for false.
150138
this._disabled = (value != null && value !== false) ? true : null;
151-
if (this._radios) {
152-
this._radios.forEach((radio) => {
153-
radio.disabled = this._disabled;
154-
})
155-
}
156139
}
157140

158141
/** Value of the radio button. */
@@ -183,6 +166,8 @@ export class MdRadioGroup implements AfterContentInit, ControlValueAccessor {
183166
this._checkSelectedRadioButton();
184167
}
185168

169+
constructor(private _change: ChangeDetectorRef) {}
170+
186171
/**
187172
* Initialize properties once content children are available.
188173
* This allows us to propagate relevant attributes to associated buttons.
@@ -244,6 +229,7 @@ export class MdRadioGroup implements AfterContentInit, ControlValueAccessor {
244229
*/
245230
writeValue(value: any) {
246231
this.value = value;
232+
this._change.markForCheck();
247233
}
248234

249235
/**
@@ -305,26 +291,10 @@ export class MdRadioButton implements OnInit {
305291
name: string;
306292

307293
/** Used to set the 'aria-label' attribute on the underlying input element. */
308-
_ariaLabel: string;
309-
@Input('aria-label')
310-
get ariaLabel(): string {
311-
return this._ariaLabel;
312-
}
313-
set ariaLabel(value: string) {
314-
this._ariaLabel = value;
315-
this._change.markForCheck();
316-
}
294+
@Input('aria-label') ariaLabel: string;
317295

318296
/** The 'aria-labelledby' attribute takes precedence as the element's text alternative. */
319-
_ariaLabelledby: string;
320-
@Input('aria-labelledby')
321-
get ariaLabelledby(): string {
322-
return this._ariaLabelledby;
323-
}
324-
set ariaLabelledby(value: string) {
325-
this._ariaLabelledby = value;
326-
this._change.markForCheck();
327-
}
297+
@Input('aria-labelledby') ariaLabelledby: string;
328298

329299
/** Whether this radio is disabled. */
330300
private _disabled: boolean;
@@ -341,10 +311,7 @@ export class MdRadioButton implements OnInit {
341311
/** Whether the ripple effect for this radio button is disabled. */
342312
@Input()
343313
get disableRipple(): boolean { return this._disableRipple; }
344-
set disableRipple(value) {
345-
this._disableRipple = coerceBooleanProperty(value);
346-
this._change.markForCheck();
347-
}
314+
set disableRipple(value) { this._disableRipple = coerceBooleanProperty(value); }
348315

349316
/**
350317
* Event emitted when the checked state of this radio button changes.
@@ -360,7 +327,6 @@ export class MdRadioButton implements OnInit {
360327
constructor(@Optional() radioGroup: MdRadioGroup,
361328
private _elementRef: ElementRef,
362329
private _renderer: Renderer,
363-
private _change: ChangeDetectorRef,
364330
public radioDispatcher: UniqueSelectionDispatcher) {
365331
// Assertions. Ideally these should be stripped out by the compiler.
366332
// TODO(jelbourn): Assert that there's no name binding AND a parent radio group.
@@ -402,7 +368,6 @@ export class MdRadioButton implements OnInit {
402368
// Notify all radio buttons with the same name to un-check.
403369
this.radioDispatcher.notify(this.id, this.name);
404370
}
405-
this._change.markForCheck();
406371
}
407372
}
408373

@@ -424,7 +389,6 @@ export class MdRadioButton implements OnInit {
424389
this.radioGroup.selected = this;
425390
}
426391
}
427-
this._change.markForCheck();
428392
}
429393
}
430394

@@ -441,7 +405,6 @@ export class MdRadioButton implements OnInit {
441405

442406
set align(v) {
443407
this.labelPosition = (v == 'start') ? 'after' : 'before';
444-
this._change.markForCheck();
445408
}
446409

447410
private _labelPosition: 'before' | 'after';
@@ -454,7 +417,6 @@ export class MdRadioButton implements OnInit {
454417

455418
set labelPosition(value) {
456419
this._labelPosition = value;
457-
this._change.markForCheck();
458420
}
459421

460422
/** Whether the radio button is disabled. */
@@ -467,7 +429,6 @@ export class MdRadioButton implements OnInit {
467429
set disabled(value: boolean) {
468430
// The presence of *any* disabled value makes the component disabled, *except* for false.
469431
this._disabled = (value != null && value !== false) ? true : null;
470-
this._change.markForCheck();
471432
}
472433

473434
ngOnInit() {

0 commit comments

Comments
 (0)