A Child component that extends a Parent component inherits the attributes of the Parent component.
Let’s start with a simple example. Here in below example c:Parent
has a description attribute with a value of “Hello!!”, and c:Child
extends c:Parent
by setting extends="c:Parent"
in its aura:component
tag.
Parent Component:
<!--Parent.cmp--> <aura:component extensible="true"> <aura:attribute name="description" type="String" default="Hello!!" /> <p>Description: {!v.description}</p> </aura:component>
Child Component:
<!--Child.cmp--> <aura:component extends="c:Parent"> <aura:set attribute="description" value="Hello World!" /> </aura:component>
Test App:
<!--Test.app--> <aura:application extends="force:slds"> <c:Parent /> <c:Child /> </aura:application>
Output:
Description: Hello!!
Description: Hello World!