Skip to content

Commit e92feef

Browse files
committed
fix(radio): select only one radio when w/out ngModel
Closes #5659
1 parent a0b5ca1 commit e92feef

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

ionic/components/radio/radio-group.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export class RadioGroup {
125125
registerOnChange(fn: Function): void {
126126
this._fn = fn;
127127
this.onChange = (val: any) => {
128+
// onChange used when there's an ngControl
128129
console.debug('radio group, onChange', val);
129130
fn(val);
130131
this.value = val;
@@ -206,7 +207,14 @@ export class RadioGroup {
206207
/**
207208
* @private
208209
*/
209-
onChange(_) {}
210+
onChange(val: any) {
211+
// onChange used when there is not an ngControl
212+
console.debug('radio group, onChange w/out ngControl', val);
213+
this.value = val;
214+
this._update();
215+
this.onTouched();
216+
this.change.emit(val);
217+
}
210218

211219
/**
212220
* @private

ionic/components/radio/test/basic/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class E2EApp {
1313
currencies: Array<string>;
1414
items: Array<{description: string, value: any}>;
1515
relationship: string;
16-
pet: string;
1716
selectedTime: number = 60;
1817

1918
constructor() {

ionic/components/radio/test/basic/main.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<code><b>relationship:</b> {{relationship}}</code>
8181
</div>
8282

83-
<div radio-group [(ngModel)]="pet" (change)="petChange($event)">
83+
<div radio-group (change)="petChange($event)">
8484
<p>
8585
<ion-radio (select)="dogSelect($event)"></ion-radio>
8686
Dogs
@@ -95,10 +95,6 @@
9595
</p>
9696
</div>
9797

98-
<div padding>
99-
<code><b>pet:</b> {{pet}}</code>
100-
</div>
101-
10298
<ion-list radio-group [(ngModel)]="someValue">
10399
<ion-item *ngFor="#item of items">
104100
<ion-label>

0 commit comments

Comments
 (0)