我有一个使用Material Design的Angular6应用程序 . 运行'ng test'时,我收到以下错误:
失败:模板解析错误:无法绑定到'value',因为它不是'mat-select'的已知属性 .
我在进口和出口中加入了MatSelectModule . 它在应用程序中工作正常但在测试期间失败 .
材料design.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatFormFieldModule, MatInputModule, MatSelectModule} from '@angular/material';
@NgModule({
imports: [MatFormFieldModule, MatInputModule, MatSelectModule],
exports: [MatFormFieldModule, MatInputModule, MatSelectModule],
})
export class MaterialDesignModule { }
选择示例:
<mat-form-field class='select_buttons'>
<mat-select (selectionChange)='typeSelection_changed($event)' [(value)]='type'>
<mat-option *ngFor="let type of types" [value]="type"> {{type.name}}</mat-option>
</mat-select>
</mat-form-field>
1 回答
您是否在spec.ts文件中导入材料模块?