// and display. Default version trims leading/trailing spaces.
formatDisplayString: (e: ComboboxEntry) => string;
- // Stub function required by ControlValueAccessor
+ // Stub functions required by ControlValueAccessor
propagateChange = (_: any) => {};
+ propagateTouch = () => {};
constructor(
private elm: ElementRef,
}
onClick($event) {
- this.registerOnTouched();
this.click$.next($event.target.value);
}
openMe($event) {
// Give the input a chance to focus then fire the click
// handler to force open the typeahead
- this.registerOnTouched();
this.elm.nativeElement.getElementsByTagName('input')[0].focus();
setTimeout(() => this.click$.next(''));
}
this.selectorChanged(
{item: this.selected, preventDefault: () => true});
}
+ this.propagateTouch();
}
// Fired by the typeahead to inform us of a change.
this.propagateChange = fn;
}
- registerOnTouched() { }
+ registerOnTouched(fn) {
+ this.propagateTouch = fn;
+ }
}
return date;
}
- // Stub function required by ControlValueAccessor
+ // Stub functions required by ControlValueAccessor
propagateChange = (_: any) => {};
+ propagateTouch = () => {};
constructor() {
this.onChangeAsDate = new EventEmitter<Date>();
}
if (this.initialDate) {
- this.current = {
- year: this.initialDate.getFullYear(),
- month: this.initialDate.getMonth() + 1,
- day: this.initialDate.getDate()
- };
+ this.writeValue(this.initialDate);
}
}
}
writeValue(value: Date) {
- if (value !== undefined) {
- this.initialDate = value;
+ if (value) {
+ this.current = {
+ year: value.getFullYear(),
+ month: value.getMonth() + 1,
+ day: value.getDate()
+ };
}
}
this.propagateChange = fn;
}
- registerOnTouched() { }
+ registerOnTouched(fn) {
+ this.propagateTouch = fn;
+ }
}