0

Im using lightning component inside Aura:Iteration. It doesnt display anything not even any error. PFB Code

<aura:component >
  <aura:attribute name="item" type="Camping_Item__c" required="true"/>
  <aura:attribute name="disabled" type="Boolean" default="false"/>
  <p>Name:
    <ui:outputText value="{!v.item.name}"/> 
   </p>

   <p>Quantity:
    <lightning:formattedNumber value="{!v.item.Quantity__c}" style="currency"/> 
   </p>

   <p>Price:
    <lightning:formattedNumber value="{!v.item.Price__c}" style="currency" /> 
   </p>

   <p>Camping :
    <lightning:input type="toggle" label="Packed" name="togglevalue" checked="{!v.item.Packed__c}" />
   <!-- <lightning:input type="toggle" packed="{!v.item.Packed__c}"/> -->
   </p>
   <p>
    <lightning:button label="Packed" onclick="{!c.packItem}" disabled="{!v.disabled}"/>                     
   </p>
</aura:component>

Camping:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
    <aura:attribute name="items" type="Camping_Item__c[]"/> 
    <aura:iteration items="{!v.items}" var="obj">
      <c:campingListItem item="{!obj}"/>
    </aura:iteration>

</aura:component>
5
  • Could you share some more code to it? From what you're saying the reason may be that your 'items' attribute may not be populated. Please provide JavaScript code and check if you actually get any records from Apex. Commented Dec 11, 2018 at 10:16
  • You don't seem to have the complete code here. In its current form items attribute on your camping component is never populated, and thus if you iterate over it, you will get no results.
    – Jayant Das
    Commented Dec 11, 2018 at 14:01
  • @JayantDas Do you mean, If i need to add query in controller to fetch the list?
    – Priya
    Commented Dec 12, 2018 at 5:42
  • Yes. You definitely need to first populate the list before you can iterate over it. In its current form, I don't see it being done, unless you are doing that already in your JS controller. If you are already querying the data and populating the list, then you can post that code here, so that specific problem can be identified.
    – Jayant Das
    Commented Dec 12, 2018 at 13:39
  • I would recommend you can try to console.log(items) first to see if the item list is actually populated, I see nothing wrong with your component at the moment.
    – Wayne Ni
    Commented Nov 7, 2022 at 12:03

1 Answer 1

0

Without a full list of the code, it seems you are doing something like that:

<aura:iteration items="{!v.items}" var="item">
    <p>Quantity:
        <lightning:formattedNumber value="{!v.item.Quantity__c}" style="currency"/> 
    </p>
    <!--  -->
</aura:iteration>

If I am correct, change your code respectively to the following pattern: "{!v.item.Quantity__c}" to "{!item.Quantity__c}" . Here no value provider is needed

If my assumption isn't correct, please, provide us with <aura:itereation> as well


Ok, I see. There's nothing wrong with your code. Try to debug the data sent by the parent component and received by children ones, that's all I can suggest you

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .