mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
radio
This commit is contained in:
@@ -18,29 +18,23 @@ import {
|
||||
})
|
||||
class IonicApp {
|
||||
constructor() {
|
||||
this.fruitsGroup1 = new ControlGroup({
|
||||
"appleCtrl": new Control("", isChecked),
|
||||
"bananaCtrl": new Control("", isChecked)
|
||||
});
|
||||
this.fruitsGroup2 = new ControlGroup({
|
||||
"grapeCtrl": new Control("", isChecked),
|
||||
"cherryCtrl": new Control("", isChecked)
|
||||
});
|
||||
this.fruits = new Control("");
|
||||
|
||||
this.fruitsForm = new ControlGroup({
|
||||
"fruitGroup1": this.fruitsGroup1,
|
||||
"fruitGroup2": this.fruitsGroup2
|
||||
"fruits": this.fruits
|
||||
});
|
||||
}
|
||||
|
||||
function isChecked(ctrl) {
|
||||
if (ctrl.checked) {
|
||||
return null;
|
||||
} else {
|
||||
return {
|
||||
'notChecked': true
|
||||
}
|
||||
}
|
||||
}
|
||||
setApple() {
|
||||
this.fruits.updateValue("apple");
|
||||
}
|
||||
|
||||
setBanana() {
|
||||
this.fruits.updateValue("banana");
|
||||
}
|
||||
|
||||
setCherry() {
|
||||
this.fruits.updateValue("cherry");
|
||||
}
|
||||
|
||||
doSubmit(event) {
|
||||
|
||||
@@ -5,26 +5,20 @@
|
||||
|
||||
<form (^submit)="doSubmit($event)" [ng-form-model]="fruitsForm">
|
||||
<div class="list-header">
|
||||
Fruit Group 1
|
||||
Fruits
|
||||
</div>
|
||||
|
||||
<ion-radio-group ng-control-group="fruitGroup1">
|
||||
<ion-radio><label>APPLE</label><input #apple type="radio" ng-control="appleCtrl"></ion-radio>
|
||||
<ion-radio><label>BANANA</label><input #banana type="radio" ng-control="bananaCtrl"></ion-radio>
|
||||
<ion-radio-group ng-control="fruits">
|
||||
<ion-radio><label>APPLE</label><input value="apple" type="radio"></ion-radio>
|
||||
<ion-radio><label>BANANA</label><input value="banana" type="radio"></ion-radio>
|
||||
<ion-radio><label>CHERRY</label><input value="cherry" type="radio"></ion-radio>
|
||||
</ion-radio-group>
|
||||
|
||||
appleCtrl.dirty: {{fruitsForm.controls.fruitGroup1.controls.appleCtrl.dirty}}<br>
|
||||
|
||||
<div class="list-header">
|
||||
Fruit Group 2
|
||||
</div>
|
||||
<ion-radio-group ng-control-group="fruitGroup2">
|
||||
<ion-radio><label>GRAPE</label><input #grape name="test" type="radio" ng-control="grapeCtrl"></ion-radio>
|
||||
<ion-radio><label>CHERRY</label><input #cherry name="test" type="radio" ng-control="cherryCtrl"></ion-radio>
|
||||
</ion-radio-group>
|
||||
|
||||
|
||||
fruits.dirty: {{fruitsForm.controls.fruits.dirty}}<br>
|
||||
fruits.value: {{fruitsForm.controls.fruits.value}}<br>
|
||||
</form>
|
||||
|
||||
<button (click)="setApple()">Select Apple</button>
|
||||
<button (click)="setBanana()">Select Banana</button>
|
||||
<button (click)="setCherry()">Select Cherry</button>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
||||
Reference in New Issue
Block a user