0

I am using Angular 9 and Angular material 9.2.4 I am trying to use MatFormField. Below is my app.module.ts

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    RegisterComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    MatToolbarModule,
    MatFormFieldModule,
    MatInputModule

  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule { }

and this is my component.html

<p>
    <mat-form-field appearance="standard">
      <mat-label>Standard form field</mat-label>
      <input matInput placeholder="Placeholder">
      <mat-hint>Hint</mat-hint>
    </mat-form-field>
</p>

But my form feild looks like

enter image description here

and I am having error in the console. Kindly suggest what I am missing in the configuration

Greenbox
  • 113
  • 1
  • 4
  • 13
  • Can you rebuild your application and check? – Chellappan வ May 22 '20 at 14:43
  • Thanks It Worked.But what is the point of rebuilding? I hav also used material toolbar. The changes got reflected instantly. Why not for form field component? – Greenbox May 22 '20 at 14:50
  • Does this answer your question? [mat-form-field must contain a MatFormFieldControl](https://stackoverflow.com/questions/46705101/mat-form-field-must-contain-a-matformfieldcontrol) – Darpan May 22 '20 at 14:56
  • @Greenbox sometime hot refresh will not for some reason. – Chellappan வ May 22 '20 at 15:11
  • No. It might be because MatInput Module. But I was getting this error even after importing the MatInputModule also. After rebuilding the errors are no more – Greenbox May 22 '20 at 15:11

1 Answers1

0

Try importing FormsModule in your imports

LogicBlower
  • 1,250
  • 1
  • 8
  • 14