Skip to content

Commit

Permalink
fix(radio): select only one radio when w/out ngModel
Browse files Browse the repository at this point in the history
Closes #5659
  • Loading branch information
adamdbradley committed Mar 6, 2016
1 parent a0b5ca1 commit e92feef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 9 additions & 1 deletion ionic/components/radio/radio-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class RadioGroup {
registerOnChange(fn: Function): void {
this._fn = fn;
this.onChange = (val: any) => {
// onChange used when there's an ngControl
console.debug('radio group, onChange', val);
fn(val);
this.value = val;
Expand Down Expand Up @@ -206,7 +207,14 @@ export class RadioGroup {
/**
* @private
*/
onChange(_) {}
onChange(val: any) {
// onChange used when there is not an ngControl
console.debug('radio group, onChange w/out ngControl', val);
this.value = val;
this._update();
this.onTouched();
this.change.emit(val);
}

/**
* @private
Expand Down
1 change: 0 additions & 1 deletion ionic/components/radio/test/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class E2EApp {
currencies: Array<string>;
items: Array<{description: string, value: any}>;
relationship: string;
pet: string;
selectedTime: number = 60;

constructor() {
Expand Down
6 changes: 1 addition & 5 deletions ionic/components/radio/test/basic/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<code><b>relationship:</b> {{relationship}}</code>
</div>

<div radio-group [(ngModel)]="pet" (change)="petChange($event)">
<div radio-group (change)="petChange($event)">
<p>
<ion-radio (select)="dogSelect($event)"></ion-radio>
Dogs
Expand All @@ -95,10 +95,6 @@
</p>
</div>

<div padding>
<code><b>pet:</b> {{pet}}</code>
</div>

<ion-list radio-group [(ngModel)]="someValue">
<ion-item *ngFor="#item of items">
<ion-label>
Expand Down

0 comments on commit e92feef

Please sign in to comment.