Activity Forums Salesforce® Discussions What is the use of the <aura:method>in Salesforce Lightning?

  • Deepak

    January 31, 2020 at 7:29 am

    Hi Krati,

    Use of <aura:method> in lightning is to define a method as part of a component's API.

    It 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.

    Example of aura:method

    In this example, we are creating a Child component aura method with two parameters. These two parameters are ‘FirstchildGreetingParam’ and ‘SecondchildGreetingParam’. These parameters are having a default value of ‘Hello’ and ‘World’ respectively.

    <aura:method name="childMessageMethod" action="{!c.getMessage}" access="public">
    <aura:attribute name="FirstchildGreetingParam" type="String" default="Hello"/>
    <aura:attribute name="SecondchildGreetingParam" type="String" default="World"/>

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos