Play Games

Search This Blog

Friday, August 5, 2016

How to iterate over a list of items in Lightning Component

We can iterate over a list of items using <aura:iteration> tag.
Example :
IterationExample.app :
<aura:application >
    <ltng:require styles="{!$Resource.SLDS100 +
         '/assets/styles/salesforce-lightning-design-system-ltng.css'}"/>
    <div class="slds">
         <c:ListDescription />
    </div>
</aura:application>
ListDescription.cmp :
<aura:component>
    <aura:attribute name="fruits" type="List"
        default="['Apple.',
            'Orange.',
            'Banana.']"/>
    <b><h2>List of Fruits :</h2></b>
    <ol>
    <aura:iteration items="{!v.fruits}" var="fruit">
        <li>{!fruit}</li>
    </aura:iteration>
    </ol>  
</aura:component>
Output :

No comments:

Post a Comment