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:component>
<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”/>
</aura:method>
-
This reply was modified 6 years, 3 months ago by
Forcetalks.