In a lightning component, I am trying to use the values in 1 array to set the values for a field in a second array. But for whatever reason I always end up with the last value of my array as the field value.
Here is the component:
<aura:attribute name="spaceTypeList" type="string[]" default="Conference/Focus Room,Copy Area,Kitchenette,Loading Dock,Electrical Room,Exterior Building,Janitorial Closet,Mothers Room,Office Area,Parking Garage,Restrooms/Locker Rooms,Stairs/Elevators,Carpet Spots/Vacuuming/Flooring,Lobbies/Corridors"/>
<aura:attribute name="detailRecord" type="Inspection_Area_Detail__c"
default="{'Inspection_Area__c':'',
'Space_Subset__c':'',
'Rating__c':'0',
}"/>
<aura:attribute name="detailList" type="Inspection_Area_Detail__c[]"/>
<ui:button label="loop test" press="{!c.loop}"/>
<aura:iteration items="{!v.detailList}" var="det">
<p> Space {!det.Space_Subset__c}</p>
</aura:iteration>
And here is the controller:
({
loop: function(component, event, helper) {
var spaceList = component.get("v.spaceTypeList");
var detail = component.get("v.detailRecord");
var List =component.get("v.detailList");
var List2 =component.get("v.testList");
for(i in spaceList){
var space =spaceList[i];
detail.Space_Subset__c = space;
console.log("detail space subset "+detail.Space_Subset__c);
List.push(detail);
List2.push(detail.Space_Subset__c);
}
component.set("v.detailList",List);
component.set("v.testList",List2);
},
})
Thank you for your help.


