Home > Back-end >  error NG8002: Can't bind to 'matDatepicker' since it isn't a known property of &
error NG8002: Can't bind to 'matDatepicker' since it isn't a known property of &

Time:01-07

I am implementing an application using Angular 15. I use Angular Material there. I need to add a date picker and after inserting the code snippet below I'm getting an error.

<mat-form-field appearance="outline">
        <mat-label>Choose a date</mat-label>
      <input formControlName="freshness" matInput [matDatepicker]="picker">
        <mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
        <mat-datepicker #picker></mat-datepicker>
    </mat-form-field>

Error:

Error: src/app/dialog/dialog.component.html:18:51 - error NG8002: Can't bind to 'matDatepicker' since it isn't a known property of 'input'.

18       <input formControlName="freshness" matInput [matDatepicker]="picker">

If you need further information to solve my issue please put a comment here.

CodePudding user response:

The following modules should be imported into your component if it's a standalone component (otherwise, in your module imports):

Besides, make sure you also import the MatInputModule and MatFormFieldModule to make them work.

  • Related