我正在尝试使用角度为6的角度材料
我的material.module.ts就像这样
import { NgModule } from '@angular/core';
import { MatButtonModule } from '@angular/material';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatTableModule } from '@angular/material/table';
import { MatSelectModule } from '@angular/material/select';
import { MatInputModule } from '@angular/material/input';
@NgModule({
imports: [
MatButtonModule,
MatIconModule,
MatTableModule,
MatFormFieldModule,
MatSelectModule,
MatInputModule
],
exports: [
MatButtonModule,
MatIconModule,
MatTableModule,
MatFormFieldModule,
MatSelectModule,
MatInputModule
]
})
export class MaterialModule {}
<mat-form-field>
<mat-select placeholder="Favorite food">
<mat-option *ngFor="let food of foods" [value]="food.value">
{{ food.viewValue }}
</mat-option>
</mat-select>
</mat-form-field>
给出错误
Uncaught Error: Template parse errors:
Can't bind to 'ngForOf' since it isn't a known property of 'mat-option'.
1. If 'mat-option' is an Angular component and it has 'ngForOf' input, then verify that it is part of this module.
请帮忙
答案 0 :(得分:0)
答案 1 :(得分:0)
在提供程序中尝试添加ErrorStateMatcher,useClass:ShowOnDirtyErrorStateMatcher