Basically i am trying to create an app showing all the Wine bottles avaialble in the SFDC database. In parent component - I am showing some other details like country etc. Once user makes a selection, I am showing List wine bottles in a child component based on the Chosen country.
<!-- PARENT COMPONENT -->
<aura:attribute name="listOfItmesInCart" type="Wine_Cart__c[]" />
<aura:handler name="addWineCartEVT" event="c:addWineCartEvent" action="{!c.cathMyAddCartEvent}"/>
< -- USER SELECTS SOME COUNTRY -->
<C: CHILD COMPONENT WILL BE CALLED AND I AM SHOWING RELATED DETAILS(WINES) IN CHILD COMPONENT. >
<aura:iteration items="{!v.listOfItmesInCart}" var="ws">
{!ws.Name__c} -- HERE IS THE PROBLEM
</aura:iteration>`
And event
<aura:event type="COMPONENT" description="Event template">
<aura:attribute name="cartItem" type="Wine_Cart__c" />
In Child Component AS I SAID,I am showing list of Records. upon Clicking some i want to pass the detail back to my parent. That i am doing by COMPONENT Events which is working fine.
<!-- CHILD COMPONENT -->
List of wine records based on the chosen country will be here in this component. upon clicking , in my ChildCompController.js i am doing the following.
<!-- CHILD COMPONENT CONRTOLLER.js -->
handleMenuSelect :
function(component,event,helper){
//I am getitng the reference of the clicked record ( say ID, Name) and passing to Parent.
var cmpEvent = component.getEvent("addWineCartEVT");
cmpEvent.setParams({"cartItem":component.get("v.clikedObject")});
cmpEvent.fire();
}
every time user click some record from child, an event will be fired and the data is being received properly in Parent comp's controller. However i am trying to add those details to a list so that i can show the clicked records on Parent object. But i am failing here. Please suggest me if you have any idea or different approaches to do this.
<!-- in my PARENT COMPONENT CONTROLLER.js -->
cathMyAddCartEvent : function(component,event,helper){
var wineCartAtt1 = event.getParam('cartItem');
var feedbacks = component.get("v.listOfItmesInCart");
feedbacks.push(wineCartAtt1); // Here I am pushing all the object details passed back from child to parent via event.
var listCart = component.get("v.listOfItmesInCart");
console.log('listCart>> '+JSON.stringify(listCart));
for (var i = 0; i < listCart.length; i++) {
NOW HOW DO KEEP ADDING OBJECTS A SINGLE LIST AND EVERY TIME A NEW SELECTION IS MADE SO THAT I CAN SHOW IT ON THE PARENT OBJECT.
}
What i am trying to achive here is showing the list of Line items added in the controller.js methods. Please help if any one has any other approaches for showing list of selected records.