Hi guys, I'm trying to do two-way binding in AngularJs and I got this error
Parser Error: The '?.' operator cannot be used in the assignment at column 48 in [data.insObj.static['AHV,IV,EO']?.employerShare=$event]
and my ngModel looks like this:
[(ngModel)]="data.insObj.static['AHV,IV,EO']?.employerShare"
how can i fix this?
UPDATE
I have this code
<input type="text" class="form-control" id="employerShare" name="data.insObj.static['AHV,IV,EO'].employerShare" placeholder="5.125%" [ngModel]="data.insObj.stat['AHV,IV,EO']?.employerShare" (ngModelChange)="data.insObj.static['AHV,IV,EO'].employerShare = $event">
when i change the input field it causes an error
Unable to read property "AHV, IV, EO" undefined
I convert this from an object to an array from this component as
this.data.insObj.stat = response.body.static; this.data.insObj.stat = this.convertObj(response.body.static);
and my function that converts it to an array looks like this:
public convertObj(obj) { var custObj = []; var array = $.map(obj, function (value, index) { custObj[index] = value; }); return custObj; }
Can you help me here why falls in ngModelChange
"static": { "AHV,IV,EO": { "id": 19, "employerShare": "0.05125", "employeeShare": "0.05125", "numberOfCompensationFound": "123.456", "insuranceNumber": "278.12312.123.456", "insuranceName": null, "man": null, "woman": null, "customerNumber": null, "subNumber": null, "contractNumber": null, "upperLimit": null, "isSuva": null, "dateOfContribution": "2017-03-02T08:30:01.095Z", "yearOfContribution": 2017, "createdAt": "2017-03-02T08:30:01.095Z", "updatedAt": "2017-03-06T11:02:22.323Z", "insuranceContributionHeaderId": 11, "companyId": 12, "insuranceContributionHeader.id": 11, "insuranceContributionHeader.insuranceName": "AHV,IV,EO", "insuranceContributionHeader.isFixed": true },