You need to sign in to do that
Don't have an account?
A G 27
lightning inheritence
Hi,
I am learning lightning, can some1 pls help me.
I have created 2 components 1 is parent and the other is child and i am using child component in application so that it wud call parent indirectly.And if i call my parentcomponent in application its throwing me an error saying "It cant be instantiated".
<--c:parentinherit-->
<aura:component extensible="true">
<h3>Hi i am parent comp</h3>
</aura:component>
<--c:childinherit-->
<aura:component extends="c:parentinherit">
<h1> I am from child</h1>
</aura:component>
In my application i am using child component.I am not getting child component header tag output. Can any1 help?
<aura:application >
Hi i am from application
<c:childinherit/>
</aura:application>
I am learning lightning, can some1 pls help me.
I have created 2 components 1 is parent and the other is child and i am using child component in application so that it wud call parent indirectly.And if i call my parentcomponent in application its throwing me an error saying "It cant be instantiated".
<--c:parentinherit-->
<aura:component extensible="true">
<h3>Hi i am parent comp</h3>
</aura:component>
<--c:childinherit-->
<aura:component extends="c:parentinherit">
<h1> I am from child</h1>
</aura:component>
In my application i am using child component.I am not getting child component header tag output. Can any1 help?
<aura:application >
Hi i am from application
<c:childinherit/>
</aura:application>
A sub component that extends a super component inherits the attributes of the super component. Use <aura:set> in the markup of a sub component to set the value of an attribute inherited from a super component.
It only inherits all of the helper methods and attributes.But the markup in the component not get inherited.
Inorder to inherit compoent markup in parent component try this way.
Please refer below links which might help you further.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/oo_whats_inherited.htm
https://developer.salesforce.com/blogs/developer-relations/2015/03/salesforce-lightning-components-by-example-component-extension.html
Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.
Thanks and Regards
All Answers
A sub component that extends a super component inherits the attributes of the super component. Use <aura:set> in the markup of a sub component to set the value of an attribute inherited from a super component.
It only inherits all of the helper methods and attributes.But the markup in the component not get inherited.
Inorder to inherit compoent markup in parent component try this way.
Please refer below links which might help you further.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/oo_whats_inherited.htm
https://developer.salesforce.com/blogs/developer-relations/2015/03/salesforce-lightning-components-by-example-component-extension.html
Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.
Thanks and Regards
I tried ur code,now also whats in parent component not coming in output
I think you missed something beacause I am able to see correct output.
Please try again by pasting the same code.
Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.
Thanks and Regards
I have a doubt here in child component we are not using extends in component,instead your calling child component in parent component itself? Why is it not working if i use extends in child component, Can u explain?
By inheriting we can call all of the helper methods, controller methods,attributes,events.But the component markup can not be accessed.
Here you are trying to access HTML markup of the component which is not possible with inheritance.So it is not working by using extends.
Hope this helps you