Newer Version Available

This content describes an older version of this product. View Latest

Setting Attributes on a Component Reference

When you include another component, such as <ui:button>, in a component, we call that a component reference to <ui:button>. You can use <aura:set> to set an attribute on the component reference. For example, if your component includes a reference to <ui:button>:

1swfobject.registerObject("clippy.codeblock-0", "9");<ui:button label="">
2    <aura:set attribute="label" value="hello"/>
3</ui:button>
4

This is equivalent to:

1swfobject.registerObject("clippy.codeblock-1", "9");<ui:button label="hello"/>
2

The latter syntax without aura:set makes more sense in this simple example.

aura:set is more useful when you want to set markup as the attribute value. For example, the <aura:set> tag specifies the markup for the else attribute in the aura:if component.

1swfobject.registerObject("clippy.codeblock-2", "9");<aura:component>
2    <aura:attribute name="display" type="Boolean" default="true"/>
3    <aura:if isTrue="{!v.display}">
4        Show this if condition is true
5        <aura:set attribute="else">
6           Show this if condition is false
7        </aura:set>
8    </aura:if>
9</aura:component>