I have a aura:method the return value from parent is NaN.

Why is my code returning NaN?

child component

<aura:method name="myAction"
       <aura:attribute name="num1" 
       <aura:attribute name="num2" 
        var params=event.getParam("arguments");
        if (params)
           var par1=params.num1;
            var par2=params.num2;
            var output=parseInt(par1)+parseInt(par2);}

Inside the parent component I have like this as below

 <c:AuraMethodChild aura:id="ChildComp"/>
 <lightning:button label="ClickMe"
 var findchild = component.find('ChildComp');
 var rtnMsgFromChildMethod = parseInt(findchild.myAction());
  • You're going to need to include more code (beyond what you just edited out) to get clarity on this.
    – David Reed
    Jun 26, 2018 at 12:52
  • Inside the child comp <aura:method name="myAction" action="{!c.myAction}" access="public"> <aura:attribute name="num1" type="integer" default="20"/> <aura:attribute name="num2" type="integer" default="30"/>
    – sheila
    Jun 26, 2018 at 13:01
  • In child comp controller: var params=event.getParam("arguments"); if (params) { var par1=params.num1; var par2=params.num2; var output=parseInt(par1)+parseInt(par2);}component.set("v.prntoutput",output);
    – sheila
    Jun 26, 2018 at 13:03
  • 2
    please edit your post rather than adding up in the comments
    – glls
    Jun 26, 2018 at 13:13
  • Does your event handler return strings that are integer values? If not, that would explain the cause of your issue. Could also be that it's it's only returning one of the values, in which case the other one wouldn't be defined and the sum would be NaN.
    – crmprogdev
    Jun 26, 2018 at 13:57

1 Answer 1


You are not returning result from the ChildComp controller method. Use below after closing of if statement

return output;

Check Salesforce Doc https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cmp_methods_sync.htm

  • thanks very much. I was not returning the value. It worked..
    – sheila
    Jun 27, 2018 at 8:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .