gpt4 book ai didi

angular-material - 无法绑定(bind)到 'errorStateMatcher',因为它不是 'input' 的已知属性

转载 作者:行者123 更新时间:2023-12-04 20:28:10 27 4
gpt4 key购买 nike

运行 npm test 时出现错误

Can't bind to 'errorStateMatcher' since it isn't a known property of 'input'. ("dth">
<input matInput placeholder="Product Name" formControlName="prod_name"
[ERROR ->][errorStateMatcher]="matcher">

我的 Spec 文件如下
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { ProductAddComponent } from './product-add.component';
import { FormControl, FormGroupDirective, FormBuilder, FormGroup, NgForm, Validators } from '@angular/forms';

describe('ProductAddComponent', () => {
let component: ProductAddComponent;
let fixture: ComponentFixture<ProductAddComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule, ReactiveFormsModule],
declarations: [ ProductAddComponent ],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(ProductAddComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});

如何提供 errorStateMatcher测试单元?

最佳答案

我认为您需要导入 MatInputModule。

关于angular-material - 无法绑定(bind)到 'errorStateMatcher',因为它不是 'input' 的已知属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53339767/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com