I am trying to save a new values into an Object from a modal, but not pushing it yet to the database. I successfully pushed the new values to the Object, but once I wanted to push another value into the Object, the previous inserted value was changed as well.
When I add another one or the 2nd value
Notice that the Test 1 values was changed to the values of the recently added ones
Here's what I have so far:
saveModal : function(component, event, helper){
var newAccountForm = component.get("v.accountForm");
var accountList = component.get("v.accountList");
var newAccList = [...accountList,newAccountForm];
component.set("v.accountList",newAccList);
helper.closeModal(component,event,helper);
},
I tried to do this accountList.push(newAccountForm)
but I get the same results, the previous inserted value was changed as well, it mirrors the latest value added.
On my 2nd creation/save, the new inserted accountList value was change prior to setting its new value.