This commit is contained in:
Max Lynch
2015-07-03 13:39:11 -05:00
parent 6ab57f916d
commit eaf6746034
4 changed files with 2 additions and 66 deletions

View File

@ -193,46 +193,3 @@ export class SegmentButton {
}
}
@IonicDirective({
selector: 'ion-segment',
host: {
'(change)': 'onChange($event.target.value)',
'(input)': 'onChange($event.target.value)',
'(blur)': 'onTouched()',
'[value]': 'value',
'[class.ng-untouched]': 'cd.control?.untouched == true',
'[class.ng-touched]': 'cd.control?.touched == true',
'[class.ng-pristine]': 'cd.control?.pristine == true',
'[class.ng-dirty]': 'cd.control?.dirty == true',
'[class.ng-valid]': 'cd.control?.valid == true',
'[class.ng-invalid]': 'cd.control?.valid == false'
}
})
export class SegmentControlValueAccessor {
constructor(cd: NgControl, renderer: Renderer, elementRef: ElementRef, segment: Segment) {
this.onChange = (_) => {};
this.onTouched = (_) => {};
this.cd = cd;
this.renderer = renderer;
this.elementRef = elementRef;
this.segment = segment;
cd.valueAccessor = this;
}
writeValue(value) {
// both this.value and setProperty are required at the moment
// remove when a proper imperative API is provided
this.value = !value ? '' : value;
this.renderer.setElementProperty(this.elementRef.parentView.render, this.elementRef.boundElementIndex, 'value', this.value);
this.segment.value = this.value;
this.segment.selectFromValue(value);
}
registerOnChange(fn) { this.onChange = fn; }
registerOnTouched(fn) { this.onTouched = fn; }
}