mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
fix(checkbox): set disabled state from FormControl
This commit is contained in:
@ -231,6 +231,13 @@ export class Checkbox extends Ion implements IonicTapInput, AfterContentInit, Co
|
|||||||
this._init = true;
|
this._init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
setDisabledState(isDisabled: boolean) {
|
||||||
|
this.disabled = isDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -17,8 +17,8 @@ export class E2EPage {
|
|||||||
|
|
||||||
appleCtrl = new FormControl(true);
|
appleCtrl = new FormControl(true);
|
||||||
bananaCtrl = new FormControl(true);
|
bananaCtrl = new FormControl(true);
|
||||||
cherryCtrl = new FormControl(false);
|
cherryCtrl = new FormControl({value: false, disabled: true});
|
||||||
grapeCtrl = new FormControl(true);
|
grapeCtrl = new FormControl({value: true, disabled: true});
|
||||||
|
|
||||||
fruitsForm = new FormGroup({
|
fruitsForm = new FormGroup({
|
||||||
'apple': this.appleCtrl,
|
'apple': this.appleCtrl,
|
||||||
@ -28,7 +28,6 @@ export class E2EPage {
|
|||||||
});
|
});
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.grapeDisabled = true;
|
|
||||||
this.grapeChecked = true;
|
this.grapeChecked = true;
|
||||||
this.standAloneChecked = true;
|
this.standAloneChecked = true;
|
||||||
}
|
}
|
||||||
@ -38,7 +37,7 @@ export class E2EPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleGrapeDisabled() {
|
toggleGrapeDisabled() {
|
||||||
this.grapeDisabled = !this.grapeDisabled;
|
this.fruitsForm.get('grape').enabled ? this.fruitsForm.get('grape').disable() : this.fruitsForm.get('grape').enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
kiwiChange(checkbox: Checkbox) {
|
kiwiChange(checkbox: Checkbox) {
|
||||||
|
@ -25,12 +25,12 @@
|
|||||||
|
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-label>Cherry, formControlName, disabled</ion-label>
|
<ion-label>Cherry, formControlName, disabled</ion-label>
|
||||||
<ion-checkbox disabled="true" formControlName="cherry"></ion-checkbox>
|
<ion-checkbox formControlName="cherry"></ion-checkbox>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-label>Grape, formControlName, checked, disabled</ion-label>
|
<ion-label>Grape, formControlName, checked, disabled</ion-label>
|
||||||
<ion-checkbox [checked]="grapeChecked" [disabled]="grapeDisabled" formControlName="grape"></ion-checkbox>
|
<ion-checkbox [checked]="grapeChecked" formControlName="grape"></ion-checkbox>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
<ion-item>
|
<ion-item>
|
||||||
|
Reference in New Issue
Block a user