我正在尝试为 aot build 编译我的代码,但我的 formArray 循环其控件时遇到了困难
<div formArrayName="energyTips">
<h3>Energy Saving Tips</h3>
<div *ngFor="let energyTip of energyTips.controls; index as i" class="panel panel-default">
<md-grid-list cols="12" rowHeight="80px">
<md-grid-tile colspan="12">
<md-input-container>
<input mdInput placeholder="Energy Tip" [formControlName]="i" type="text" required>
<md-error *ngIf="energyTips.at(i).hasError('required')">Please fill the energy saving tip details before adding another one</md-error>
</md-input-container>
<button *ngIf="i == (energyTips.controls.length - 1 )" class="circle-buttons" md-fab (click)="addEnergyTip($event,energyTip)" color="primary" [disabled]="energyTips.at(i).hasError('required')"><md-icon>add</md-icon></button><span *ngIf="addGreenScreenForm.controls.energyTips.controls.length > 1"><button class="circle-buttons" md-fab (click)="removeEnergyTip(i)" color="primary"><md-icon>remove</md-icon></button></span>
</md-grid-tile>
</md-grid-list>
</div>
</div>
我不确定如何将这些部分重写
controls.length
为energyTips.controls
aot 兼容代码。