错误:类型“ AbstractControl”缺少类型“ FormGroup”中的以下属性:控件,registerControl,addControl,removeControl,

VR7

我已经使用Android制作了天气API网络应用程序,

链接:-https: //stackblitz.com/edit/maximlweatherapp

APP网址:-https: //maximlweatherapp.stackblitz.io

我在Visual Studio代码中使用了相同的代码,并且工作正常,没有给出任何错误,但是在StackBlitz中,却出现了错误。两者的唯一区别是在Visual Studio中,已安装Angular Version 8,但是我在这里使用Angular版本9,请任何人都能看到代码有什么问题并建议我进行一些更改,

我的Visual Studio代码输出的工作结果 我的工作结果来自Visual Studio代码输出。

yurzui

在Angular 9中默认的AOT模式下,模板编译器比JIT模式下严格。

例如,在以下代码中:

[formGroup]="checkcity.at(itemindex)"

checkcity.at方法返回,AbstractControl并且与所需的类型不匹配FormGroupDirective

您可以自己铸造:

html

[formGroup]="getFormGroupAt(itemindex)"

ts

getFormGroupAt(i: number) {
  return this.checkcity.at(i) as FormGroup;
}

分叉的Stackblitz

在您使用的每个位置使用内置的$ any()函数checkcity.at(itemindex)

$any(checkcity.at(itemindex))

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章