Simple addition using Aura #inSalesforce

Simple addition using Aura #inSalesforce


<aura:component >
    <aura:attribute name = 'number1' type = 'Integer' default = '15'></aura:attribute>
    <aura:attribute name = 'number2' type = 'Integer' default = '20'></aura:attribute>
    <aura:attribute name = 'sum' type = 'Integer'></aura:attribute>
    <div>
        <p>Add</p><lightning:button label = 'Add' onclick = '{!c.addMethod}'/>
        <p>{!v.number1} + {!v.number2} = {!v.sum}</p>
    </div>
</aura:component>



({
    addMethod : function(component, event, helper) {     
        var number1 = component.get("v.number1");
        var number2 = component.get("v.number2");
        var sumResult = number1 + number2;
        component.set('v.sum', sumResult);
    }
})

Comments