You need to sign in to do that
Don't have an account?
JAGDISH MORE
aura:method is not working properly. Parent component is not calling child component?
ParentComponent:-
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
<aura:attribute name="Name" type="String" default="---------------- This is a Parent Message------------" />
<Canteen:ChildComponent aura:id="childCmp"/>
<lightning:button variant="brand" label="Call Aura Method"
onclick="{!c.callAuraMethod}" />
<p>"{!v.Name}"</p>
</aura:component>
parentcomponentcontroller:-
({
callAuraMethod : function(component, event, helper) {
var childCmp = component.find("childCmp");
var retnMsg = childCmp.childMethod('Amit');
component.set("v.Name",retnMsg);
}
})
Childcomponent:-
<aura:component >
<aura:method name="childMethod" action="{!c:getMessage}" access="public" description="Child Method">
<aura:attribute name="Name" type="String" default="Jagdish"/>
</aura:method>
{v.Name}
</aura:component>
Childcomponentcontroller:-
({
getMessage : function(component, event) {
var parameter = event.getParam('arguments');
debugger;
if(parameter){
debugger;
var par1 = params.Name;
return "##############This is a message returned by the child whith parameter:: "+par1+"##############";
}
return "TEST";
}
})
Call to child component is not happning? I am not understanding why?
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
<aura:attribute name="Name" type="String" default="---------------- This is a Parent Message------------" />
<Canteen:ChildComponent aura:id="childCmp"/>
<lightning:button variant="brand" label="Call Aura Method"
onclick="{!c.callAuraMethod}" />
<p>"{!v.Name}"</p>
</aura:component>
parentcomponentcontroller:-
({
callAuraMethod : function(component, event, helper) {
var childCmp = component.find("childCmp");
var retnMsg = childCmp.childMethod('Amit');
component.set("v.Name",retnMsg);
}
})
Childcomponent:-
<aura:component >
<aura:method name="childMethod" action="{!c:getMessage}" access="public" description="Child Method">
<aura:attribute name="Name" type="String" default="Jagdish"/>
</aura:method>
{v.Name}
</aura:component>
Childcomponentcontroller:-
({
getMessage : function(component, event) {
var parameter = event.getParam('arguments');
debugger;
if(parameter){
debugger;
var par1 = params.Name;
return "##############This is a message returned by the child whith parameter:: "+par1+"##############";
}
return "TEST";
}
})
Call to child component is not happning? I am not understanding why?