Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Setting Attributes Inherited from a Super Component
Use <aura:set> in the markup of a sub component to set the value of an inherited attribute.
Let's look at an example. Here is the c:setTagSuper component.
1<!--c:setTagSuper-->
2<aura:component extensible="true">
3 <aura:attribute name="address1" type="String" />
4 setTagSuper address1: {!v.address1}<br/>
5</aura:component>c:setTagSuper outputs:
1setTagSuper address1:The address1 attribute doesn't output any value yet as it hasn't been set.
Here is the c:setTagSub component that extends c:setTagSuper.
1<!--c:setTagSub-->
2<aura:component extends="c:setTagSuper">
3 <aura:set attribute="address1" value="808 State St" />
4</aura:component>c:setTagSub outputs:
1setTagSuper address1: 808 State StsampleSetTagExc:setTagSub sets a value for the address1 attribute inherited from the super component, c:setTagSuper.
If you’re using a component by making a reference to it in your component, you can set the attribute value directly in the markup. For example, c:setTagSuperRef makes a reference to c:setTagSuper and sets the address1 attribute directly without using aura:set.
1<!--c:setTagSuperRef-->
2<aura:component>
3 <c:setTagSuper address1="1 Sesame St" />
4</aura:component>c:setTagSuperRef outputs:
1setTagSuper address1: 1 Sesame St