function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfdc fishsfdc fish 

Cannot Read property setparams in lighting components

Am quite new to lightning and trying to sumup two numbers so far i have created component for suming numbers  in one component and another compnennt for display the result.
But getting error as "This page has an error. You might just need to refresh it. Action failed: c$UserInput$controller$Pressme [Cannot read property 'setParams' of null]  Failing descriptor: {c$UserInput$controller$Pressme}"

Here is my code:
 UserInput.cmp
 <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
<aura:registerEvent name="loadMyEvent" type="c:Result"/>
    <aura:attribute name="input1" type="integer"/>
<p>hello from component1</p>
<br/>
<ui:inputnumber aura:id="input1" label="first value" required="true"/>
<ui:inputnumber aura:id="input2" label="secondvalue" required="true"/>
<ui:button label="sum" press="{!c.Pressme}"/>
<br/>
</aura:component>

UserInputController.js

({
Pressme:function(component,event,helper){
    alert('test');
var get_num1=component.find("input1").get("v.value");
    alert('test1=='+get_num1);
var get_num2=component.find("input2").get("v.value");
    alert('test2=='+ get_num2);
var res=parseInt(get_num1)+parseInt(get_num2);
    alert('result=='+ res);
//var evt=$A.get("e.c:Result");
    component.getEvent("Result").setParams({"pass_result":res}).fire();
//evt.setparam({"pass_result": 5});
    //evt.fire();
}
})


DisplayResult.cmp

<aura:component >
<aura:attribute name="Get_Result" type="Integer"/>
<aura:handler event="c:Result" action="{!c.getvaluefromApplicationEvent}"/>
The Result is {!v.Get_Result}
</aura:component>

DisplayResultcontroller.js

({
getvaluefromApplicationEvent:function(cmp,event){
var showresultvalue= event.getparam("pass_result");
cmp.set("v.Get_Result",showResultValue);
}
})

Result.evt

<aura:event type="application" description="Event template">
<aura:attribute name="pass_result" type="string"/>
</aura:event>

Thanks in advance...
sfdcMonkey.comsfdcMonkey.com
hi sfdc fish 
i catch some error in you code, always keep in mind that JS is case-sensetive so here name and Name is difference(for example).
update you code like:

userInputController :
({
Pressme:function(component,event,helper){
    alert('test');
var get_num1 = component.find("input1").get("v.value");
    alert('test1=='+get_num1);
var get_num2=component.find("input2").get("v.value");
    alert('test2=='+ get_num2);
var res=parseInt(get_num1)+parseInt(get_num2);
    alert('result=='+ res);
 var evt = $A.get("e.c:Result");
   evt.setParams({ "pass_result": res });
        evt.fire();
   
}
})
Display Result controller 
({
     getvaluefromApplicationEvent:function(cmp,event){
      var showResultValue= event.getParam("pass_result"); // getparam and getParam both are different 
      cmp.set("v.Get_Result",showResultValue);   // showresultvalue and showResultValue are also treat as differnt 
     },
})
output -:
User-added image
i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks 
http://sfdcmonkey.com
http://www.sfdcmonkey.com/community/
 
sfdc fishsfdc fish
Thank you so much
....it's working fine.....
sfdcMonkey.comsfdcMonkey.com
welcome :)
if my answer helps you mark it as best answer so it make proper solution for others in future :)
hs dsd 10hs dsd 10
I had a link to a consumer report so I needed to take an additional step of unchecking:
Security / Session Settings / Enable clickjack protection for consumer visualforce pages with fashionable headers page (https://flyandspincasting.com/).