aura:method in Salesforce

Use <aura:method> to define a method as part of a component’s API.

This enables you to directly call a method in a component’s client-side controller instead of firing and handling a component event.

Using <aura:method> simplifies the code needed for a parent component to call a method on a child component that it contains.

Sample Code:

Lightning App:

<aura:application >


Lightning Component:

<aura:component >
    <aura:method name=”compMtd” action=”{!c.callFromCompMetd}”>
        <aura:attribute type=”String” name=”Str” default=”testing”/>
    <ui:button label=”Click” press=”{!c.callBtn}”/>

Lightning Controller:

callBtn : function(component, event, helper) {
    callFromCompMetd : function(component, event, helper) {
        var params = event.getParam(‘arguments’);
        if (params) {
            var param1 = params.Str;



Leave a Reply