If you have multiple modules make sure you're importing the MatFormFieldModule
in every module. It's not sufficient to just import it in the root module.
For example, I have a CommonWidgetsModule which contains some common widgets (my own) and you'll see I'm importing MatFormFieldModule
and MatInputModule
// common-widgets.module.ts
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
@NgModule({
imports: [
CommonModule,
SharedModule,
RouterModule,
MatFormFieldModule,
MatInputModule,
// import other MatModules...
],
declarations: DECLARATIONS,
exports: DECLARATIONS
})
export class CommonWidgetsModule { }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…