mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 13:01:01 +08:00
fix(input): checked attr can be an empty string or no value
This commit is contained in:
@ -3,6 +3,7 @@ import {NgControl} from 'angular2/common';
|
||||
|
||||
import {Form} from '../../util/form';
|
||||
import {Item} from '../item/item';
|
||||
import {isTrueProperty} from '../../util/util';
|
||||
|
||||
/**
|
||||
* The checkbox is no different than the HTML checkbox input, except
|
||||
@ -99,7 +100,7 @@ export class Checkbox {
|
||||
|
||||
set checked(val) {
|
||||
if (!this._disabled) {
|
||||
this._checked = (val === true || val === 'true');
|
||||
this._checked = isTrueProperty(val);
|
||||
this.onChange(this._checked);
|
||||
this._item && this._item.setCssClass('item-checkbox-checked', this._checked);
|
||||
}
|
||||
@ -111,7 +112,7 @@ export class Checkbox {
|
||||
}
|
||||
|
||||
set disabled(val) {
|
||||
this._disabled = (val === true || val === 'true');
|
||||
this._disabled = isTrueProperty(val);
|
||||
this._item && this._item.setCssClass('item-checkbox-disabled', this._disabled);
|
||||
}
|
||||
|
||||
@ -132,8 +133,10 @@ export class Checkbox {
|
||||
* the checked value.
|
||||
* https://github.com/angular/angular/blob/master/modules/angular2/src/forms/directives/shared.ts#L34
|
||||
*/
|
||||
writeValue(value) {
|
||||
this.checked = value;
|
||||
writeValue(val) {
|
||||
if (val !== null) {
|
||||
this.checked = val;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user