1

I have used mat-date-picker inside my application, the html file looks like this :

  <mat-form-field>
<input matInput [matDatepicker]="picker" formControlName="date" placeholder="Choose a date">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>

I have used the exact same piece of code in my another component and it works, but in this component it displays the error:

ERROR Error: mat-form-field must contain a MatFormFieldControl.

Even though the page is loading after the error, the button of date picker doesnot get displayed and i cannot select a date.

Atul Stha
  • 1,404
  • 8
  • 23
  • 46
  • Where is the closing Tag for ``? I mean something like that: `` and check if you have the `[formGroup]="form"` in your opening tag for form etc. Could you post the part of `*.component.ts` for this? – k.vincent Apr 30 '18 at 20:28

1 Answers1

13

Make sure you've imported the module MatInputModule.

G. Tranter
  • 16,766
  • 1
  • 48
  • 68