Skip to content

rodrigo0097/angular-date-value-accessor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/

About

Home of the Angular DateValueAccessor for <input type="date">

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 62.8%
  • HTML 19.4%
  • CSS 11.3%
  • JavaScript 6.5%