Using <aura:method>
, I am not able to call child component controller function from parent controller. Below code.
Parent Component
<aura:component access="global" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" >
<c:questionSectionPolitic aura:id="childQuestion"
qstList="{!qstList}"
recordId="{!v.recordId}"
questionA="{!v.questionA}"
questionB="{!v.questionB}"
questionC="{!v.questionC}"
questionD="{!v.questionD}"
questionE="{!v.questionE}"
/>
<button type="button" aura:id="saveAndReturn" class="slds-button" onclick="{!c.save}" >Save and return
</button>
</aura:component>
Parent Controller
save : function(component,helper,event){
var contactBtnId = component.get("v.contactBtnId");
var contactName = document.getElementById('name'+contactBtnId).value;
var recordId = component.get("v.recordId");
var childComponent = component.find("childQuestion");
childComponent.getScoreMethod(contactBtnId,contactName,recordId);
},
Child Component
<aura:component access="global">
<aura:method name="getScoreMethod" action="{!c.calcScore}" access="PUBLIC">
<aura:attribute name="contactId" type="String" />
<aura:attribute name="contactName" type="String" />
<aura:attribute name="recordId" type="String" />
</aura:method>
</aura:component>
Child Controller
calcScore : function(component,event,helper){
var contactId = event.getParam("contactId");
var contactName = event.getParam("contactName");
console.log('Inside Calc Score');
}
Now getting the error [childComponent.getScoreMethod is not a function]. What is wrong here ?