Hellom's Studio.

ng7 项目打包 ng build --prod --aot 报错

字数统计: 134阅读时长: 1 min
2019/07/12 Share

报错描述:

项目打包时 运行 ng build --prod --aot 报错

报错信息:"property 'controls' does not exist on type 'AbstractControl' "

解决方案:

1
2
3
4
5
6
7
8

<!-- html -->
<div class="upload-img-item" *ngFor="let item of getFormArrayProductDetailsImg();let i = index;" [formGroup]="addProductForm.get(['productDetailsImg', i])">
<img class="wh100" [src]="item.get('detailImg').value | safeUrl" alt="">
</div>

<!-- 以下写法 --aot会报错 -->
<div *ngFor="let item of addProductForm.get('productDetailsImg').controls;let i = index;"></div>
1
2
3
4
5
6
7

//.ts
//获取产品图片
public getFormArrayProductDetailsImg = (): Array<any> => {
const formArray: FormArray = this.addProductForm.get('productDetailsImg') as FormArray;
return formArray.controls;
}
CATALOG
  1. 1. 报错描述:
  2. 2. 解决方案: