Tag Archives: Lightning JS Controller

Call A Method From Another Method in Same Lightning Controller

Lightning Component:

<aura:component>
    <!--Component Start--> 
    <div class="slds-m-around_xx-large">
        <lightning:button variant="Brand" class="slds-button" label="Submit" onclick="{!c.methodOne}"/>
    </div>
    <!--Component End-->
</aura:component>

Lightning JS Controller:

({
    //Method One
    methodOne : function(component, event, helper){
        //Call methodTwo from methodone
        var action = component.get('c.methodTwo');
        $A.enqueueAction(action);
    },
    
    //Method Two
    methodTwo : function(component, event, helper){
        alert('Method 2');
    }
})