Here is the basic example for iterating a collection or list of values in lightning component using aura:iteration tag.
Step 1:
Open Developer Console
Step 2:
Click File --> New --> Lightning Component --> Enter name as "ConditionalComponent" and Submit.
Clear the existing code and paste the below one,
Step 1:
Open Developer Console
Step 2:
Click File --> New --> Lightning Component --> Enter name as "ConditionalComponent" and Submit.
Clear the existing code and paste the below one,
- <aura:component >
- <aura:attribute name="edit" type="Boolean"/>
- <aura:if isTrue="{!v.edit}">
- <ui:button label="Edit" />
- <aura:set attribute="else">
- <ui:button label="Edit" disabled="true"/>
- </aura:set>
- </aura:if>
- </aura:component>
Step 3:
Use existing app or new one and paste the below code.
For "edit" attribute i set attribute value as true in the below code. In this case button will be visible, if you set "edit" attribute as false, Button will will disabled.
- <aura:application >
- <c:ConditionalComponent edit="true"/>
- </aura:application>
For True condition, set attribute value as below,
- <c:ConditionalComponent edit="true"/>
For False condition, set attribute value as below,
- <c:ConditionalComponent edit="false"/>
No comments:
Post a Comment