我导入了MatFormFieldModule
这样的:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
//import { MaterialModule } from './material/material.module';
import {MatFormFieldModule} from '@angular/material/form-field';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
// MaterialModule,
MatFormFieldModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
在app.component.html
我有(直接取自 API 文档):
<mat-form-field>
<input matInput placeholder="Input">
</mat-form-field>
ERROR Error: mat-form-field must contain a MatFormFieldControl.
有任何想法吗?
我得到了错误:
ERROR Error: mat-form-field must contain a MatFormFieldControl.