Home > Software design >  Module '"@angular/material"' has no exported member 'MatFormFieldModule
Module '"@angular/material"' has no exported member 'MatFormFieldModule

Time:09-16

I am going to use MatFormFieldModule in Angular 12.

I imported this module from @angular/material and @NgModule like below:

import {MatFormFieldModule} from '@angular/material';


@NgModule({
....

imports: [
  MatFormFieldModule,
  ...
  ],
...

})

And used this MatFormFieldModule in html file

<mat-form-field>
  ...
</mat-form-field>

But I got the error like this:

Error: src/app/app.module.ts:9:3 - error TS2305: Module '"@angular/material"' has no exported member 'MatFormFieldModule'.

9   MatFormFieldModule

Not sure about the problem.

CodePudding user response:

If you check the documentation for the material form field you can notice that the right import path for the MatFormFieldModule is @angular/material/form-field. Please try this:

import {MatFormFieldModule} from '@angular/material/form-field'; 
  • Related