function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dan LordDan Lord 

set attributes on sub-component (aura)

I have this aura code:
<aura:iteration items="{!v.giaList}" var="giaRecord" indexVar="number">
        <c:GIO_GauListItem
          origGiaRecord="{!giaRecord}"
          giaRecord="{!giaRecord}"
        />
      </aura:iteration>
In GIO_GauListItem.cmp, I have:
<aura:attribute name="giaRecord" type="Object" />
  <aura:attribute name="origGiaRecord" type="Object" />
But, in the sub-component, when giaRecord changes, so does origGiaRecord. Are these values being passed by reference from the parent component? that is, not actually two instances of the object?

How can I maintain the original values in the copy?
Best Answer chosen by Dan Lord
Dan LordDan Lord
(I have to say that I'm a bit disappointed in this forum. I've posted 3 questions over the last few years and had to answer all the questions.)

For this question, the answer can be found here: 
https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.migrate_data_binding
 

All Answers

Dan LordDan Lord
addendum to original question:

What I would really like to do is this:
 
<aura:iteration items="{!v.giaList}" var="giaRecord" indexVar="number">
        <c:GIO_GauListItem
          originalGiftName="{!giaRecord.gia.General_Accounting_Unit__r.Name}"
          originalFundId={!giaRecord.gia.Fund_Id__c}"
          giaRecord="{!giaRecord}"
        />
      </aura:iteration>
along with
<aura:attribute name="giaRecord" type="Object" />
  <aura:attribute name="originalGiftName" type="String" />
  <aura:attribute name="originalFundId" type="String" />
but, that has the same effect; when the giaRecord changes, so do those values.
 
Dan LordDan Lord
(I have to say that I'm a bit disappointed in this forum. I've posted 3 questions over the last few years and had to answer all the questions.)

For this question, the answer can be found here: 
https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.migrate_data_binding
 
This was selected as the best answer
Dan LordDan Lord
See also: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_data_binding.htm