Newer Version Available
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 docsample:setTagSuper component.
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<!--docsample:setTagSuper-->
18<aura:component extensible="true">
19 <aura:attribute name="address1" type="String" />
20 setTagSuper address1: {!v.address1}<br/>
21</aura:component>
22docsample:setTagSuper outputs:
1setTagSuper address1:The address1 attribute doesn't output any value yet as it hasn't been set.
Here is the docsample:setTagSub component that extends docsample:setTagSuper.
1swfobject.registerObject("clippy.codeblock-2", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<!--docsample:setTagSub-->
18<aura:component extends="docsample:setTagSuper">
19 <aura:set attribute="address1" value="808 State St" />
20</aura:component>
21docsample:setTagSub outputs:
1setTagSuper address1: 808 State StsampleSetTagExdocsample:setTagSub sets a value for the address1 attribute inherited from the super component, docsample: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, docsample:setTagSuperRef makes a reference to docsample:setTagSuper and sets the address1 attribute directly without using aura:set.
1swfobject.registerObject("clippy.codeblock-4", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<!--docsample:setTagSuperRef-->
18<aura:component>
19 <docsample:setTagSuper address1="1 Sesame St" />
20</aura:component>
21docsample:setTagSuperRef outputs:
1swfobject.registerObject("clippy.codeblock-5", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17setTagSuper address1: 1 Sesame St
18