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
Anji PavuluriAnji Pavuluri 

This page has an error. You might just need to refresh it. Action failed: c:Handler3$controller$test [componet is not defined] Failing descriptor: {c:Handler3$controller$test}

Handler3.cmp:
------------------
<aura:component >
    <aura:attribute name="aval" type="Integer"/>
    <aura:attribute name="bval" type="Integer"/>
    <aura:attribute name="cval" type="Integer"/>
    <aura:handler name="init" value="{!this}" action="{!c.test}"/>
    <lightning:card title="Calculation">
        A value:{!v.aval}<br/>
        B value:{!v.bval}<br/>
        C value:{!v.cval}
    </lightning:card>
</aura:component>

Handler3Controller.js
----------------------------
({
    test: function(component, event, helper) {
        var a=component.get("v.aval");
        var b=component.get("v.bval");
        var cval=a+b;
        componet.set("v.cval",cval);
        
        
    }
})
Handler3_App.app
-------------------------
<aura:application extends ="force:slds">
    <c:Handler3 aval="10" bval="20" />
</aura:application>
ShivankurShivankur (Salesforce Developers) 
Hi Anji,

You have a spell mistake in your controller code.

Please try to paste as below and check:
({
    test: function(component, event, helper) {
        var a=component.get("v.aval");
        var b=component.get("v.bval");
        var cval=a+b;
        component.set("v.cval",cval);
        
        
    }
})
Hope above information helps. Please mark as Best Answer so that it can help others in future.

Thanks.
 
Suraj Tripathi 47Suraj Tripathi 47

Hi Anji,

Please find the solution.

test: function(c,e,h){
                var a=c.get("v.aval");
                var b=c.get("v.bval");
        var cval=a+b;
             console.log("outside if:::"+cval);
        if(cval){
            console.log("Inside if:::"+cval);
           c.set("v.cval",cval);

        }


     }

Actually, In your code, there is no data inside this variable "cval" so how you can set if there is no data.

c.set("v.cval",cval);

I have correct your code if there is no data then it will not enter inside the if statement.
Please let me know it is working or not.
Please mark it as the Best Answer if it helps you.
Thank You