mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(radio): add ability to set ng-model on a radio group and check the corresponding radio button with that value
added a test for ng-model with a radio. references #530
This commit is contained in:
@@ -22,6 +22,18 @@ class E2EApp {
|
||||
this.fruitsForm = new ControlGroup({
|
||||
"fruits": this.fruits
|
||||
});
|
||||
|
||||
this.currenciesControl = new Control("");
|
||||
|
||||
this.currencyForm = new ControlGroup({
|
||||
"currenciesControl": this.currenciesControl
|
||||
});
|
||||
|
||||
this.currencies = ['USD', 'EUR'];
|
||||
this.selectedCurrency = 'EUR';
|
||||
|
||||
this.relationship = 'friends';
|
||||
|
||||
}
|
||||
|
||||
setApple() {
|
||||
|
||||
@@ -32,15 +32,37 @@
|
||||
|
||||
</form>
|
||||
|
||||
<p aria-hidden="true" class="align-center">
|
||||
<div aria-hidden="true" class="align-center">
|
||||
<button (click)="setApple()" outline small>Select Apple</button>
|
||||
<button (click)="setBanana()" outline small>Select Banana</button>
|
||||
<button class="e2eCherry" (click)="setCherry()" outline small>Select Cherry</button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<div padding>
|
||||
<code>fruits.dirty: {{fruitsForm.controls.fruits.dirty}}</code><br>
|
||||
<code>fruits.value: {{fruitsForm.controls.fruits.value}}</code><br>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form (submit)="doSubmit($event)" [ng-form-model]="currencyForm">
|
||||
<ion-radio-group ng-control="currenciesControl">
|
||||
<ion-list-header>
|
||||
Currencies
|
||||
</ion-list-header>
|
||||
<ion-radio *ng-for="#currency of currencies" [checked]="currency==selectedCurrency" [value]="currency">{{currency}}</ion-radio>
|
||||
</ion-radio-group>
|
||||
</form>
|
||||
|
||||
<div padding>
|
||||
<code>currenciesControl.value: {{currencyForm.controls.currenciesControl.value}}</code>
|
||||
</div>
|
||||
|
||||
<ion-radio-group [(ng-model)]="relationship">
|
||||
<ion-radio value="friends">Friends</ion-radio>
|
||||
<ion-radio value="enemies">Enemies</ion-radio>
|
||||
</ion-radio-group>
|
||||
|
||||
<div padding>
|
||||
<code>relationship: {{relationship}}</code>
|
||||
</div>
|
||||
|
||||
</ion-content>
|
||||
|
||||
Reference in New Issue
Block a user