Setting aura: attribute values in Lightning components
Here I'm going to share some basic stuff like, set some default values to attributes and access them in lightning component.Set attribute default values in Component
[<aura:attribute name="sampleString" type="string" default="This is sample String"/>
String Output: <ui:outputText value="{!v.sampleString}" /><br/>]
An array of items of a defined type
[ <aura:attribute name="sampleArray" type="String[]" default="['Red', 'blue','green']"/>
Array Output: <ui:outputText value="{!v.sampleArray[0]}" />]
An ordered collection of items
[<aura:attribute name="sampleList" type="List" default="['Red', 'blue','green']"/>
List Output: <ui:outputText value="{!v.sampleArray[1]}" />]
A collection that contains no duplicate elements. The order for set items is not guaranteed
[<aura:attribute name="sampleSet" type="Set" default="['Red','blue','green']"/>
Set Output: <ui:outputText value="{!v.sampleMap[01]}" />
<aura:iteration items="{!v.sampleSet}" var="TempItem">
Set Item: {!TempItem}
</aura:iteration> ]
A collection that maps keys to values. A map can’t contain duplicate keys
[ <aura:attribute name="sampleMap" type="Map" default="{01 : 'A', 02: 'B', 03: 'C'}"/>
Map Output: <ui:outputText value="{!v.sampleMap[01]}" />]
Next post will share you set the attribute values from js controller to attributes.
COMMENTS