Error
This page has an error. You might just need to refresh it. Action failed: c:LC_1103_Eg4_SumUpEven$controller$calc [ation is not defined] Failing descriptor: {c:LC_1103_Eg4_SumUpEven$controller$calc}
Class
public class LC_1103_Eg4_SumUpEven {
@AuraEnabled
public static Integer sumuptoeven(integer numb)
{
integer Res=1;
integer count=0;
while(count<numb){
Res=Res+count;
count=count+2;
}
Return Res;
}
}
component
<aura:component controller="LC_1103_Eg4_SumUpEven">
<aura:attribute name="num" type="Integer"/>
<aura:attribute name="Result" type="Integer"/>
<lightning:card title="SUM">
<lightning:input label="Enter the Number" value="{!v.num}"/>
<lightning:button label="Calulate" onclick="{!c.calc}"/><br/>
<lightning:input label="Result" value="{!v.Result}"/>
</lightning:card>
</aura:component>
controller
({
calc : function(component, event, helper) {
var n=component.get("v.num");
var action=component.get("c.sumuptoeven");
action.setParams({"numb":n});
ation.setCallback(this,function(response){
var state=response.getState();
if(state=='SUCCESS')
{
var res=response.getReturnValue();
component.set("v.result",res);
}
});
$A.enqueueAction(action);
}
})
Application
<aura:application extends="force:slds">
<c:LC_1103_Eg4_SumUpEven/>
</aura:application>
{ }
to properly format the code and add details about the problem you are facing.