fix(inputs): fix form onChange/onTouch

This commit is contained in:
Adam Bradley
2016-01-07 09:22:17 -06:00
parent f74606dc1b
commit 2070e58e3e
3 changed files with 59 additions and 17 deletions

View File

@ -55,9 +55,6 @@ export class Checkbox {
) {
_form.register(this);
this.onChange = (_) => {};
this.onTouched = (_) => {};
if (ngControl) {
ngControl.valueAccessor = this;
}
@ -114,6 +111,20 @@ export class Checkbox {
this.checked = value;
}
/**
* @private
*/
onChange(val) {
// TODO: figure the whys and the becauses
}
/**
* @private
*/
onTouched(val) {
// TODO: figure the whys and the becauses
}
/**
* @private
* Angular2 Forms API method called by the view (NgControl) to register the

View File

@ -55,7 +55,9 @@ export class RadioButton {
private _form: Form,
private _renderer: Renderer,
private _elementRef: ElementRef
) {}
) {
_form.register(this);
}
/**
* @private
@ -88,6 +90,13 @@ export class RadioButton {
public set isChecked(isChecked) {
this._renderer.setElementAttribute(this._elementRef, 'aria-checked', isChecked);
}
/**
* @private
*/
ngOnDestroy() {
this._form.deregister(this);
}
}
@ -184,8 +193,19 @@ export class RadioGroup {
}
}
public onChange = (_:any) => {};
public onTouched = () => {};
/**
* @private
*/
onChange(val) {
// TODO: figure the whys and the becauses
}
/**
* @private
*/
onTouched(val) {
// TODO: figure the whys and the becauses
}
/**
* @private

View File

@ -91,9 +91,6 @@ export class Toggle {
this.lastTouch = 0;
this.mode = config.get('mode');
this.onChange = (_) => {};
this.onTouched = (_) => {};
if (ngControl) {
ngControl.valueAccessor = this;
}
@ -164,13 +161,6 @@ export class Toggle {
this.onChange(this._checked);
}
/**
* @private
*/
writeValue(value) {
this.checked = value;
}
/**
* @private
*/
@ -209,6 +199,27 @@ export class Toggle {
this.isActivated = false;
}
/**
* @private
*/
writeValue(value) {
this.checked = value;
}
/**
* @private
*/
onChange(val) {
// TODO: figure the whys and the becauses
}
/**
* @private
*/
onTouched(val) {
// TODO: figure the whys and the becauses
}
/**
* @private
*/
@ -225,7 +236,7 @@ export class Toggle {
ngOnDestroy() {
this.removeMoveListener();
this.toggleEle = this.addMoveListener = this.removeMoveListener = null;
this.form.deregister(this);
this._form.deregister(this);
}
/**