From b44ff4138cd55d20295f0e95ab6a208dd7b83c72 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Thu, 12 Jan 2017 17:02:06 -0500 Subject: [PATCH] fix(checkbox): set disabled state from FormControl --- src/components/checkbox/checkbox.ts | 7 +++++++ src/components/checkbox/test/basic/app-module.ts | 7 +++---- src/components/checkbox/test/basic/main.html | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/checkbox/checkbox.ts b/src/components/checkbox/checkbox.ts index 6d2f22ea55..c44ef685bf 100644 --- a/src/components/checkbox/checkbox.ts +++ b/src/components/checkbox/checkbox.ts @@ -231,6 +231,13 @@ export class Checkbox extends Ion implements IonicTapInput, AfterContentInit, Co this._init = true; } + /** + * @private + */ + setDisabledState(isDisabled: boolean) { + this.disabled = isDisabled; + } + /** * @private */ diff --git a/src/components/checkbox/test/basic/app-module.ts b/src/components/checkbox/test/basic/app-module.ts index 6db2907631..bcd214b028 100644 --- a/src/components/checkbox/test/basic/app-module.ts +++ b/src/components/checkbox/test/basic/app-module.ts @@ -17,8 +17,8 @@ export class E2EPage { appleCtrl = new FormControl(true); bananaCtrl = new FormControl(true); - cherryCtrl = new FormControl(false); - grapeCtrl = new FormControl(true); + cherryCtrl = new FormControl({value: false, disabled: true}); + grapeCtrl = new FormControl({value: true, disabled: true}); fruitsForm = new FormGroup({ 'apple': this.appleCtrl, @@ -28,7 +28,6 @@ export class E2EPage { }); constructor() { - this.grapeDisabled = true; this.grapeChecked = true; this.standAloneChecked = true; } @@ -38,7 +37,7 @@ export class E2EPage { } toggleGrapeDisabled() { - this.grapeDisabled = !this.grapeDisabled; + this.fruitsForm.get('grape').enabled ? this.fruitsForm.get('grape').disable() : this.fruitsForm.get('grape').enable(); } kiwiChange(checkbox: Checkbox) { diff --git a/src/components/checkbox/test/basic/main.html b/src/components/checkbox/test/basic/main.html index 5f403370ff..5373529bd2 100644 --- a/src/components/checkbox/test/basic/main.html +++ b/src/components/checkbox/test/basic/main.html @@ -25,12 +25,12 @@ Cherry, formControlName, disabled - + Grape, formControlName, checked, disabled - +