Home  >  Forum  >  Angular
Post New Query

Error: "MatDatepicker: No provider found for DateAdapter



Asked on June 25, 2020
I am creating Angular Material Datepicker .

<mat-form-field>
  <mat-label>Select Date</mat-label>
  <input matInput [matDatepicker]="dt">
  <mat-datepicker-toggle matSuffix [for]="dt"></mat-datepicker-toggle>
  <mat-datepicker #dt></mat-datepicker>
</mat-form-field> 

But getting following error.

Error: "MatDatepicker: No provider found for DateAdapter. You must import one of the following modules at your application root: MatNativeDateModule, MatMomentDateModule, or provide a custom implementation."






Replied on June 25, 2020
You are missing

import { MatNativeDateModule } from '@angular/material/core';

For Datepicker, make sure you have following settings.

app.module.ts

import { MatInputModule } from '@angular/material/input';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatNativeDateModule } from '@angular/material/core';

@NgModule({
  imports: [
    ------
    MatInputModule, 
    MatDatepickerModule,
    MatNativeDateModule
  ],
  ------
})
export class AppModule { }



Write Answer








©2020 concretepage.com | Privacy Policy | Contact Us