尝试diff'[object Object]'`时出错需要传递错误信息

时间:2018-05-29 13:47:02

标签: json angular angular-reactive-forms

我通过[ngValue]="operator.value"时工作正常。当我将ngValue更改为"operator"时,错误会更改为

  

"试图区分' [对象]'"

我正在尝试发布完整数组而不是值。

HTML代码:

<select class="form-control" formControlName="operators" (change)="onChangeOfUdfParamValue(i,operators)">
 <option [ngValue]="opera" *ngFor="let opera of formula.controls.operators.value" [attr.selected]="opera.selected ? true : null" >
 {{opera.display}}
</option>
 </select>

JSON格式:

"operators": [
                    {
                        "display": "=",
                        "value": ">",
                        "active": true,
                        "selected": false
                    },
                    {
                        "display": ">",
                        "value": ">",
                        "active": true,
                        "selected": false
                    },
                    {
                        "display": "<",
                        "value": "<",
                        "active": true,
                        "selected": false
                    }
                ]

1 个答案:

答案 0 :(得分:0)

错误原因

  

对象数组已转换为对象

两种解决方法:

解决方案1: Change object to new formArray().

解决方案2: change formcontrolName to other name which will create new formcontrol().