Directive that uses the native date picker and binds the typed value to Date.
npm i @ng-not-found/ng-typed-date --save
This te directive has the purpose of facilitating the use of date fields, making the binding in the model in a typed way.
When working with dates in Angular, it binds with a string and that's usually not what we need. We need it to be a valid Date.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { FormsModule } from '@angular/forms';
import { NgTypedDateModule } from '@ng-not-found/ng-typed-date';
@NgModule({
declarations: [
AppComponent,
],
imports: [
FormsModule,
BrowserModule,
AppRoutingModule,
NgTypedDateModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
<form #form="ngForm">
<input type="date" [(ngModelDate)]="data" name="data" />
<input type="datetime-local" [(ngModelDate)]="data" name="data" />
</form>
Name | Type |
---|---|
min | Date / string |
max | Date / string |