This commit is contained in:
Max Lynch
2015-05-09 13:01:48 -05:00
parent a93434165e
commit 7b853dba16
3 changed files with 15 additions and 3 deletions

View File

@ -70,7 +70,8 @@ export class Switch {
* ControlDirective to update the value internally.
*/
writeValue(value) {
this.checked = value;
// Convert it to a boolean
this.checked = !!value;
}

View File

@ -8,10 +8,19 @@
<ion-switch control="enableFun">
Enable Fun?
</ion-switch>
<ion-switch control="enableIceCream">
Enable Ice Cream?
</ion-switch>
<ion-switch control="enablePizza">
Enable Pizza?
</ion-switch>
</ion-list>
Is fun enabled? <b>{{form.controls.enableFun.value}}</b>
<br>
Is ice cream enabled? <b>{{form.controls.enableIceCream.value}}</b>
<br>
Is pizza enabled? <b>{{form.controls.enablePizza.value}}</b>
</form>
</ion-content>

View File

@ -12,7 +12,9 @@ class IonicApp {
var fb = new FormBuilder();
this.form = fb.group({
enableFun: ['', Validators.required]
enableFun: ['', Validators.required],
enableIceCream: [false, Validators.required],
enablePizza: [true, Validators.required]
});
}