You didn't definecannot set new properties on a record returned from the defaults for Account sobject type:
It should be likeserver or retrieved using cmp.get('v.[attributeName]'). The workaround is to make a copy of the object that: you want to set a new property on.
<aura:attribute
type="Account"
name="acc"
default="{ 'sobjectType': 'Account',
'Name': '',
'Rating': 'Hot'
}"
/>
Your ControllerJS would be:
({
init : function(cmp, event, helper) {
console.log('init');
var action = cmp.get('c.getAcc');
action.setCallback(this, function(response) {
// You cannot set a new property on an object returned from the server
var acc = response.getReturnValue();
var// accTYou =can JSON.stringify(acc);set a new property on a copy
var accT = JSON.stringify(JSON.parse(accTacc));
accT.Rating = 'Hot T';
cmp.set('v.acc', accT);
});
$A.enqueueAction(action);
}
})