angular-date-value-accessor
Version:
A set of ControlValueAccessors for Angular to work with Browser's native date input elements. Now you can use <input type='date'> with template-driven and reactive forms!
28 lines (27 loc) • 1.15 kB
TypeScript
import { ElementRef, Renderer2 } from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
import * as i0 from "@angular/core";
/**
* The accessor for writing a value and listening to changes on a date input element in local time.
*
* ### Example
* `<input type="date" name="myBirthday" ngModel useValueAsLocalDate>`
*
* See also:
* What is the correct way to set and get HTMLInputElement.valueAsDate using local Dates?
* https://stackoverflow.com/a/53033442
*/
export declare class LocalDateValueAccessor implements ControlValueAccessor {
private renderer;
private elementRef;
onInput: (date?: Date) => void;
onChange: any;
onTouched: () => void;
constructor(renderer: Renderer2, elementRef: ElementRef);
writeValue(date?: Date): void;
registerOnChange(fn: (_: any) => void): void;
registerOnTouched(fn: () => void): void;
setDisabledState(isDisabled: boolean): void;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalDateValueAccessor, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<LocalDateValueAccessor, "[useValueAsLocalDate]", never, {}, {}, never, never, true>;
}