My task is to update the value "customer.signature", but I am facing an issue with my code. The JSON and HTML seem to be error-free, so the problem lies within my JS code. While "data.signature" updates correctly, "data.customer.signature" does not.
The JSON response from the "Accounts" endpoint:
{
"signature": "newAccountSignatur",
"signatureEnabled": true,
"defaultMsisdn": "08282709909013",
"httpForwardingAddress": "http://null.dev.to",
"smtpForwardingAddress": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="79151803180b0c0a39170c1...01"> ]</a>",
"customer": {
"signature": "newCustomerSignatur",
"id": 10339,
"companyName": "Gerd Webapp Test v2.0.x",
"diallingCodeId": 43,
},
}
JS function:
$scope.saveSignature = function () {
if (AuthService.isAuth()) {
Accounts.one().get().then(
function (resultOk) {
resultOk.data.customer.signature = $scope.newCustomerSig;
resultOk.data.signature = $scope.newAccountSig;
$log.d("resultOk: ", resultOk.data);
resultOk.data.put().then(
function (resultOk) {
alert("Saved");
$log.d("Accountinfo ok: ", resultOk);
$scope.user = resultOk.data;
},
function (resultError) {
$log.d("Accountinfo error: ", resultError);
ErrorService.showApiError(resultError);
}
);
}
);
}
};
HTML form:
<form name="signature" ng-sub>
<div>
<textarea rows="5" cols="40" ng-model="newAccountSig" ng-trim="false" placeholder="{{user.signature}}"></textarea>
</div>
<i> Personal Signature </i><br/>
<div>
<i> Second Example</i><br/>
<textarea rows="5" cols="40" ng-model="newCustomerSig" ng-trim="false" placeholder="{{user.customer.signature}}"></textarea>
</div>
<i>Information for me: </i>
<p>Current value in account.signature = </p>
<span>{{user.signature| stringIfBlank:'-'}}</span>
<p>Current value in account.customer.signature = </p>
<span>{{user.customer.signature| stringIfBlank:'-'}}</span>
</form>