Home of the Angular DateValueAccessor for <input type="date">
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
angular-date-value-accessor bump version to v.0.0.2 -- handles null values now Feb 23, 2017
demo upates to the readme, more dominant screenshot Oct 13, 2016
.gitignore wip Oct 2, 2016
LICENSE
README.md
article.md article typos Oct 13, 2016

README.md

DateValueAccessor for Angular

NPM version

Screenshot

A custom value accessor for Angular 2.
Now you can use JavaScript Date objects directly with two-way data bindings (ngModel) as well as with reactive forms (formControlName/formControl).

Examples:

You have to explicitly opt-in by adding the attribute useValueAsDate to a date input control:

<input type="date" name="myBirthday" ngModel useValueAsDate>

OR

<input type="date" name="myBirthday" [(ngModel)]="myBirthday" useValueAsDate>

OR

<input type="date" formControlName="myBirthday" useValueAsDate>

Installation:

Download the package via NPM:

npm install --save angular-date-value-accessor

Then import the module via NgModule:

// app.module.ts

import { DateValueAccessorModule } from 'angular-date-value-accessor';

@NgModule({
  imports: [
    DateValueAccessorModule
  ]
})
export class AppModule { }

Now you can apply the "useValueAsDate" to your date input controls.

Demo

There is a demo at: http://johanneshoppe.github.io/angular-date-value-accessor/