作者:林琳奇 | 来源:互联网 | 2022-12-09 09:17
如何从单元测试中访问注入的ngControl?如何解决错误?
在组件中
constructor(
@Self() @Optional() public ngControl: NgControl
) { }
ngOnInit(): void {
this.ngControl.valueChanges
在单元测试中
beforeEach(() => {
fixture = TestBed.createComponent(component);
fixture.detectChanges();
执行测试时得到错误
TypeError: Cannot read property 'valueChanges' of null