implementing a convert to a timestamp on the fly
kvzhkv opened this issue · 1 comments
kvzhkv commented
Hi, I need a timestamp value in my formControl and trying to implement it with your great useValueAsDate directive. (Thanks!!!)
I actually have updated writeValue() to update value in the view like this:
writeValue(value: number): void {
if (!value) {
this._renderer.setElementProperty(this._elementRef.nativeElement, 'value', null);
return;
}
this._renderer.setElementProperty(this._elementRef.nativeElement, 'valueAsDate', this.convertFromTimestamp(value));
}
convertFromTimestamp(value: number): Date {
return new Date(value);
}
but how to convert date value from input to model?
I realize that registerOnChange() should be updated, but how?
Does anybody have an ideas?
JohannesHoppe commented
This feature goes beyond the necessary functionality. A conversion to a timestamp can be done elsewhere in the code.