Angular MatFormFieldModule类不是角度模块

Angular MatFormFieldModule类不是角度模块,angular,angular-material,Angular,Angular Material,我不明白为什么MatFormFieldModule不是角度模块 在登录的HTML部分,我使用 在这里,它告诉我: 未知的html标记表单字段 在导入MatFormFieldModule的AuthModule中,我被告知: MatFormFieldModule类不是角度模块 login.component.html: <mat-toolbar> <mat-toolbar-row> <h1 style="text-align: center !im

我不明白为什么MatFormFieldModule不是角度模块

在登录的HTML部分,我使用

在这里,它告诉我:

未知的html标记表单字段

在导入MatFormFieldModule的AuthModule中,我被告知:

MatFormFieldModule类不是角度模块

login.component.html:

<mat-toolbar>
  <mat-toolbar-row>
    <h1 style="text-align: center !important; width: 100%">Login Page</h1>
  </mat-toolbar-row>
</mat-toolbar>

<div class="row">
  <div class="col-md-12">
    <form [formGroup]="loginForm" (ngSubmit)="onSubmit()">
      <div class="container">

        <div class="form-group">
          <mat-form-field>
            <label>
              <input formControlName="email" matInput placeholder="E-Mail">
            </label>
<!--            <mat-hint *ngIf="loginForm.controls.email.errors">Email is required</mat-hint>-->
          </mat-form-field>
        </div>

        <div class="form-group">
          <mat-form-field>
            <label>
              <input formControlName="password" matInput placeholder="Password">
            </label>
<!--            <mat-hint *ngIf="loginForm.controls.password.errors">Password is required</mat-hint>-->
          </mat-form-field>
        </div>

        <button mat-flat-button color="primary" [disabled]="!loginForm.valid" type="submit">Login</button>

      </div>

    </form>
  </div>
</div>
这是我得到的错误:

错误:src/app/auth/components/login/login.component.html:1:1-错误 NG8001:“mat toolbar”不是已知元素:

  • 如果“mat toolbar”是一个角度组件,则验证它是否是此模块的一部分
  • 如果“mat toolbar”是一个Web组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到此组件的“@NgModule.schemas”中 以抑制此消息
  • 一,~~~~~~~~~~~~~

    我尝试了以下步骤:

    但这对我没用

    这是否与project angular从版本11更新到版本12有关


    如果您需要更多信息,请告诉我。

    因此,我通过导出模块修复了它。AppModule显然缺少MatFormFieldModule

    @NgModule({
      declarations: [
        LoginComponent,
        RegisterComponent,
        ResetPasswordComponent
      ],
      imports: [
        CommonModule,
        AuthRoutingModule,
        ReactiveFormsModule,
        FormsModule,
        MatFormFieldModule,
        MatButtonModule,
        MatInputModule,
        MatToolbarModule
      ],
      exports: [
        LoginComponent,
        RegisterComponent,
        ResetPasswordComponent,
        MatInputModule,
        MatFormFieldModule
      ]
    })
    export class AuthModule {
    }
    
    @NgModule({
      declarations: [
        LoginComponent,
        RegisterComponent,
        ResetPasswordComponent
      ],
      imports: [
        CommonModule,
        AuthRoutingModule,
        ReactiveFormsModule,
        FormsModule,
        MatFormFieldModule,
        MatButtonModule,
        MatInputModule,
        MatToolbarModule
      ],
      exports: [
        LoginComponent,
        RegisterComponent,
        ResetPasswordComponent,
        MatInputModule,
        MatFormFieldModule
      ]
    })
    export class AuthModule {
    }