Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saicharanreddyk/b8dfcc0565c31b50dbf9dcad689d2a88 to your computer and use it in GitHub Desktop.
Save saicharanreddyk/b8dfcc0565c31b50dbf9dcad689d2a88 to your computer and use it in GitHub Desktop.
Lightning - Display Array of elements or List or Set
To display Array of elements ot lists or set we can use iteration in lightning.
<aura:iteration items="{!v.student}" var="a">
items -- data on which we need to iterate
var -- The name of the variable to use for each item inside the iteration
aura:iteration iterates over a collection of items and renders the body of the tag for each item
Component
**********************************************************************************
<aura:component >
<aura:attribute name="student" type="List" default="['ABC','DEF','GHK','LMN','OPQ']" />
<aura:attribute name="age" type="Integer[]" default="[12,23,45,56,67]" />
<aura:attribute name="course" type="Set" default="['A','D','G','L','O']" />
<lightning:layout multipleRows="true">
<lightning:layoutItem size="4" padding="around-small">
<aura:iteration items="{!v.student}" var="a">
{!a}<br/>
</aura:iteration>
</lightning:layoutItem>
<lightning:layoutItem size="4" padding="around-small">
<aura:iteration items="{!v.age}" var="a">
{!a}<br/>
</aura:iteration>
</lightning:layoutItem>
<lightning:layoutItem size="4" padding="around-small">
<aura:iteration items="{!v.course}" var="a">
{!a}<br/>
</aura:iteration>
</lightning:layoutItem>
</lightning:layout>
</aura:component>
**********************************************************************************
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment