I am 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]
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 raises an error of
Cannot read property 'AHV,IV,EO' of undefined
I am converting this from an object to an array from the component like this
this.data.insObj.stat = response.body.static;
this.data.insObj.stat = this.convertObj(response.body.static);
and my function that converts it to 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 out in here, why is falling down 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
},