我有一个函数返回FormArray的控件:
getFormFControls() {
return this.form.get('opts') ? (<FormArray>this.formQuestions.get('opts')).controls : null;
}但是,在运行Lint检查时,我会得到以下错误:
Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead.
我尝试过许多方法来解决这个问题,但是当它是FormArray.controls: AbstractControl[]时,我找不到解决方案。
有人能帮我吗?
试图删除并在末尾添加“as FormArray”,但我得到了一个错误。
我需要解决这个问题,不要把评论放在行中忽略林特。
发布于 2022-11-04 19:11:03
您的错误是试图告诉您更改以下内容:
(<FormArray>this.formQuestions.get('opts')).controls : null;对此:
(this.formQuestions.get('opts') as FormArray).controls : null;它们是等同的,但是第一个已经不再使用了,因为它与JSX混淆了。
https://stackoverflow.com/questions/74321499
复制相似问题