Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'mat-datepicker-actions' is not a known element - best solution required

I have imported MatDatepickerModule and getting mat-datepicker-actions are not known. I guess there is some other module that needs to import. Here is code snippet:

<mat-form-field appearance="fill" class="example-form-field">
   <mat-label>Choose a date</mat-label>
   <input matInput [matDatepicker]="datepicker">
   <mat-datepicker-toggle matSuffix [for]="datepicker"></mat-datepicker-toggle>
   <mat-datepicker #datepicker>
     <mat-datepicker-actions>
       <button mat-button matDatepickerCancel>Cancel</button>
       <button mat-raised-button color="primary" matDatepickerApply>Apply</button>
     </mat-datepicker-actions>
   </mat-datepicker>
 </mat-form-field>

Note: anyone provides solution within the angular-material library, not third party (normally has too much size). I'll be thankful.

like image 824
WasiF Avatar asked Oct 25 '25 03:10

WasiF


1 Answers

You need to import MatDatepickerModule and MatNativeDateModule into your module for which your component is a part of. I use below for Angular 11

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

    @NgModule({
      declarations: [
        ...
      ],
      imports: [
        ...
        MatNativeDateModule,
        MatDatepickerModule
        ...
like image 157
Nikhil Avatar answered Oct 27 '25 17:10

Nikhil