ERROR错误:mat-form-field必须包含MatFormFieldControl。用于使用角形材料7的日期选择器

问题描述 投票:0回答:1

我正在开发简单的日期选择器应用程序。我检查了相关的职位,但无法解决此错误。我正严格按照有角度的材料举例说明。请指导我。HTML文件


<mat-form-field>
    <input matInput [matDatepicker]="picker" placeholder="Choose a date">
    <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
    <mat-datepicker #picker></mat-datepicker>
  </mat-form-field>

材料模块

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {MatDatepickerModule} from '@angular/material/datepicker';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatNativeDateModule } from '@angular/material/core';


@NgModule({
  declarations: [],
  imports: [
    CommonModule,
    MatDatepickerModule,
    MatFormFieldModule,
    MatNativeDateModule,

  ],
  exports: [
    MatDatepickerModule,
    MatFormFieldModule,
    MatNativeDateModule,

  ]
})
export class MaterialModule { }
angularjs angularjs-directive angular-material
1个回答
0
投票

您需要在模块的导入部分中添加MatInputModule

© www.soinside.com 2019 - 2024. All rights reserved.