我在FormArray中有一个选择标记,并且我已经从api中使用http获取了该选择的选项。我有以下错误帮助我。找不到不同的支持对象'[object Object]'
CashPluckingLeafComponent.html:44 ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
<div formArrayName="leaf_grade">
<div *ngFor="let grades of cplForm.controls.leaf_grade.controls; let i=index">
<div [formGroupName]="i">
<div class="form-group">
<label>Leaf Grade {{i + 1}}</label>
<select name="grade" formControlName="grade" class="form-control" id="grade">
<option *ngFor='let lg of grades' [value]="lg.name">{{ lg.name }}</option>
</select>
<small *ngIf="!cplForm.controls.leaf_grade.controls[i].controls.grade.valid && cplForm.controls.leaf-grade.controls[i].controls.grade.touched">
Leaf Grade is required
</small>
<div>
<span *ngIf="cplForm.controls.leaf_grade.controls.length > 1" class="remove-form-control">
<a (click)="removeGradeData(i)">
<i class="fa fa-times fa-fw" aria-hidden="true"></i> Remove
</a>
</span>
</div>
</div>
</div>
</div>
</div>
等级从含有的console.log(等级)
(2)[对象,对象] 0:对象 1:对象 长度:2
您正将一个对象传递给'* ngFor',但它只支持一个数组。我没有办法从这里获得帮助,因为无法从提供的信息中派生出传递给'* ngFor'的信息。 –
添加您尝试循环的数据格式。这个错误解释了你正试图循环对象或其他东西,而不是'Array' – mayur
console.log(等级)输出:(2)[Object,Object] 0:Object 1:Object length:2 – gudboisgn