mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 13:32:54 +08:00
make checkboxes work
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
import {Component, Template, NgElement, PropertySetter} from 'angular2/angular2';
|
import {Component, Template, NgElement, PropertySetter} from 'angular2/angular2'
|
||||||
import {ComponentConfig} from 'ionic2/config/component-config';
|
import {ComponentConfig} from 'ionic2/config/component-config'
|
||||||
|
|
||||||
export let CheckboxConfig = new ComponentConfig('checkbox');
|
export let CheckboxConfig = new ComponentConfig('checkbox')
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ion-checkbox',
|
selector: 'ion-checkbox',
|
||||||
@ -9,7 +9,7 @@ export let CheckboxConfig = new ComponentConfig('checkbox');
|
|||||||
checked: 'checked'
|
checked: 'checked'
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
'click': 'onClick'
|
'click': 'onClick()'
|
||||||
},
|
},
|
||||||
services: [CheckboxConfig]
|
services: [CheckboxConfig]
|
||||||
})
|
})
|
||||||
@ -30,21 +30,36 @@ export let CheckboxConfig = new ComponentConfig('checkbox');
|
|||||||
})
|
})
|
||||||
export class Checkbox {
|
export class Checkbox {
|
||||||
constructor(
|
constructor(
|
||||||
@PropertySetter('attr.role') setRole: Function,
|
|
||||||
@PropertySetter('attr.aria-checked') setChecked: Function,
|
|
||||||
@PropertySetter('attr.aria-invalid') setInvalid: Function,
|
|
||||||
@PropertySetter('attr.aria-disabled') setDisabled: Function,
|
|
||||||
configFactory: CheckboxConfig,
|
configFactory: CheckboxConfig,
|
||||||
element: NgElement
|
element: NgElement,
|
||||||
|
@PropertySetter('attr.role') setAriaRole: Function,
|
||||||
|
@PropertySetter('attr.aria-checked') setAriaChecked: Function,
|
||||||
|
@PropertySetter('attr.aria-invalid') setAriaInvalid: Function,
|
||||||
|
@PropertySetter('attr.aria-disabled') setAriaDisabled: Function
|
||||||
) {
|
) {
|
||||||
this.domElement = element.domElement;
|
this.domElement = element.domElement
|
||||||
this.domElement.classList.add('item');
|
this.domElement.classList.add('item')
|
||||||
this.config = configFactory.create(this);
|
this.config = configFactory.create(this)
|
||||||
|
|
||||||
setRole('checkbox');
|
setAriaRole('checkbox')
|
||||||
setChecked('true')
|
setAriaInvalid('false')
|
||||||
setInvalid('false');
|
setAriaDisabled('false')
|
||||||
setDisabled('false');
|
|
||||||
|
this.setAriaRole = setAriaRole
|
||||||
|
this.setAriaChecked = setAriaChecked
|
||||||
|
this.setAriaInvalid = setAriaInvalid
|
||||||
|
this.setAriaDisabled = setAriaDisabled
|
||||||
|
}
|
||||||
|
|
||||||
|
set checked(checked) {
|
||||||
|
this._checked = checked
|
||||||
|
this.setAriaChecked(checked)
|
||||||
|
}
|
||||||
|
get checked() {
|
||||||
|
return this._checked
|
||||||
|
}
|
||||||
|
onClick() {
|
||||||
|
this.checked = !this.checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
// Checkbox
|
// Checkbox
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
|
.checkbox {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.checkbox-on {
|
.checkbox-on {
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<ion-list>
|
<ion-list>
|
||||||
<ion-list-header>Some Checkboxes</ion-list-header>
|
<ion-list-header>Some Checkboxes</ion-list-header>
|
||||||
|
|
||||||
<ion-checkbox>
|
<ion-checkbox [checked]="true">
|
||||||
Apples
|
Apples
|
||||||
</ion-checkbox>
|
</ion-checkbox>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user