0

I have a parent component controller from which I am calling a Child controller function using aura:method as described in https://developer.salesforce.com/blogs/developer-relations/2017/04/lightning-inter-component-communication-patterns.html

But now working. Giving the error:

c:WspPOLITICS$controller$save [childComponent.callScoremethod is not a function]

Parent Component

   <aura:component access="global">
   <!--some code-->
      <c:questionSectionPolitic aura:id="childQuestion" />
     <button type="button" aura:id="saveAndReturn" class="slds-button slds-button--neutral slds-button slds-button--brand slds-hide" onclick="{!c.save}" >Save and return
     </button>
 </aura:component>

ParentComponent Controller

save : function(component,helper,event){
  var childComponent = component.find("childQuestion");
  console.log('childComponent-->'+childComponent);
  childComponent.callScoremethod(); }

Child Component

   <aura:component access="global">
   <aura:method name="callScoremethod" action="{!c.calcScore}" access="PUBLIC"></aura:method>
   <!--some code-->
   </aura:component>

Child Controller

calcScore : function(component,event,handler){
 <!Some logic-->
 }
4
  • I have already gone through the same and as they suggested I have used the aura:method
    – Brav
    Commented Aug 16, 2017 at 12:40
  • Does your components are in the same namespace? You should try to put a global access on the aura:method like this: access="global" Commented Aug 16, 2017 at 12:44
  • It was already in public access but I tried it with global access but same error
    – Brav
    Commented Aug 16, 2017 at 12:49
  • well, hehe, i copy posted your code and it seems to work =P
    – glls
    Commented Aug 16, 2017 at 13:05

0

Browse other questions tagged .