我正在尝试在功能模块(UserProfilesModule)中使用<mat-form-field>
,但出现此错误:
ERROR in src/app/user-profiles/components/users/users.component.html:3:5 - error NG8001: 'mat-form-field' is not a known element: 1. If 'mat-form-field' is an Angular component, then verify that it is part of this module. 2. If 'mat-form-field' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
这是我的 shared.module.ts
const modules = [
CommonModule,
ReactiveFormsModule,
FormsModule,
RouterModule,
MatListModule,
MatIconModule,
MatFormFieldModule,
MatButtonModule,
MatInputModule,
];
@NgModule({
declarations: [UserInfoComponent],
imports: modules,
exports: modules
})// @ts-ignore
export class SharedModule { }
这是我的 users.component.html
<div>
<form>
<mat-form-field appearance="standart">
<mat-label>Search</mat-label>
<input matInput type="text" placeholder="Username">
<mat-icon matSuffix>search</mat-icon>
</mat-form-field>
</form>
</div>
和 user-profiles.module.ts
@NgModule({
declarations: [UsersComponent],
imports: [
SharedModule
]
})
// @ts-ignore
export class UserProfilesModule { }