javascript - TypeError:form.updateValueAndValidity 不是 Angular 中的函数
问题描述
我正在尝试测试这些方法,但收到此错误:TypeError: form.updateValueAndValidity is not a function
onGoToStep(step: string): void {
this.activeStepIndex =
step === 'prev' ? this.activeStepIndex - 1 : this.activeStepIndex + 1
this.onSetForm()
}
onSetForm(): void {
this.masterForm.map(form => form.updateValueAndValidity())
}
这是我的spec.ts
describe('onGoToStep', () => {
it('makes expected calls', () => {
spyOn(component, 'onSetForm').and.callThrough();
component.masterForm = ['']
fixture.detectChanges()
component.onGoToStep('prev');
expect(component.onSetForm).toHaveBeenCalled();
});
});
显然问题出在form
我不知道如何绕过它。
有没有办法解决这个问题?
解决方案
推荐阅读
- matlab - 如何使用旋转角度和轴来旋转 3D 平面?
- unity3d - 音量变化滞后
- bluetooth - bluetoothctl utilty 中的 [prompts] 是什么意思
- computer-vision - Image.open(os.path.join(origin_path,name)).convert('P') 有什么问题吗?
- angular - 在角度 7 中使用更改检测时如何以某种方式通知用户?
- c# - 关于初始化数据库的错误 - 实体框架 6
- c# - 无法在 Visual Studio 2019 中使用连接的服务
- amazon-web-services - 如何使用 Aws Cognito 和 Aws Amplify 对用户进行身份验证
- azure-devops - Azure DevOps:组规则
- python-3.x - 如何将二分图转换为无二分图