fix(toggle/checkbox): allow value to be programmatically updated while disabled (#10304)

fixes #9730
This commit is contained in:
Brandy Carney
2017-02-03 11:52:42 -05:00
committed by Justin Willis
parent 305cc623a7
commit b8ee3018b5
4 changed files with 21 additions and 2 deletions

View File

@ -158,7 +158,7 @@ export class Checkbox extends Ion implements IonicTapInput, AfterContentInit, Co
* @private
*/
_setChecked(isChecked: boolean) {
if (!this._disabled && isChecked !== this._checked) {
if (isChecked !== this._checked) {
this._checked = isChecked;
if (this._init) {
this.ionChange.emit(this);

View File

@ -27,6 +27,9 @@ export class E2EPage {
'grape': this.grapeCtrl
});
public checked: boolean = false;
public disabled: boolean = false;
constructor() {
this.grapeChecked = true;
this.standAloneChecked = true;

View File

@ -88,4 +88,20 @@
<pre aria-hidden="true" padding>{{formResults}}</pre>
<ion-item>
<ion-label>Checkbox / Toggle</ion-label>
<ion-checkbox [(ngModel)]="checked" [disabled]="disabled"></ion-checkbox>
<ion-toggle [(ngModel)]="checked" [disabled]="disabled"></ion-toggle>
</ion-item>
<ion-item>
<ion-label>checked</ion-label>
<ion-checkbox [(ngModel)]="checked"></ion-checkbox>
<ion-toggle [(ngModel)]="checked"></ion-toggle>
</ion-item>
<ion-item>
<ion-label>disabled</ion-label>
<ion-checkbox [(ngModel)]="disabled"></ion-checkbox>
<ion-toggle [(ngModel)]="disabled"></ion-toggle>
</ion-item>
</ion-content>

View File

@ -229,7 +229,7 @@ export class Toggle extends Ion implements IonicTapInput, AfterContentInit, Cont
* @private
*/
_setChecked(isChecked: boolean) {
if (!this._disabled && isChecked !== this._checked) {
if (isChecked !== this._checked) {
this._checked = isChecked;
if (this._init) {
this.ionChange.emit(this);