mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
setDisabledState(isDisabled: boolean) {
|
||||
this.disabled = isDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
@ -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) {
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
<ion-item>
|
||||
<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-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>
|
||||
|
Reference in New Issue
Block a user