fix(radio): do not use strict comparison for values

Closes #5660
This commit is contained in:
Adam Bradley
2016-03-05 12:36:57 -06:00
parent b219de5f9f
commit a2f858bb56
4 changed files with 20 additions and 5 deletions

View File

@ -142,7 +142,7 @@ export class RadioButton {
* @private
*/
ngOnInit() {
if (this._group && isDefined(this._group.value) && this._group.value === this.value) {
if (this._group && isDefined(this._group.value) && this._group.value == this.value) {
this.checked = true;
}
}

View File

@ -148,7 +148,7 @@ export class RadioGroup {
// check this radiobutton if its value is
// the same as the radiogroups value
radioButton.checked = (radioButton.value === this.value);
radioButton.checked = (radioButton.value == this.value);
if (radioButton.checked) {
// if this button is checked, then set it as
@ -183,7 +183,7 @@ export class RadioGroup {
remove(button: RadioButton) {
let index = this._btns.indexOf(button);
if (index > -1) {
if (button.value === this.value) {
if (button.value == this.value) {
this.value = null;
}
this._btns.splice(index, 1);

View File

@ -14,6 +14,7 @@ class E2EApp {
items: Array<{description: string, value: any}>;
relationship: string;
pet: string;
selectedTime: number = 60;
constructor() {
this.fruits = new Control('apple');

View File

@ -99,7 +99,7 @@
<code><b>pet:</b> {{pet}}</code>
</div>
<ion-list radio-group [(ngModel)]="someNumber">
<ion-list radio-group [(ngModel)]="someValue">
<ion-item *ngFor="#item of items">
<ion-label>
{{ item.description }}
@ -110,7 +110,21 @@
</ion-list>
<div padding>
<code><b>someNumber:</b> {{someNumber}}</code>
<code><b>someValue:</b> {{someValue}}</code>
</div>
<ion-list radio-group [(ngModel)]="selectedTime">
<ion-list-header>
Time
</ion-list-header>
<ion-item>
<ion-label>60 minutes</ion-label>
<ion-radio value="60"></ion-radio>
</ion-item>
<ion-item>
<ion-label>30 minutes</ion-label>
<ion-radio value="30"></ion-radio>
</ion-item>
</ion-list>
</ion-content>