Newer Version Available
Calling Component Methods
Use this syntax to call a method in JavaScript code.
cmp is a reference to the component. arg1, … argN is an optional comma-separated list of arguments passed to the method.
Let’s look at an example of a component containing a button. The handler for the button calls a component method instead of firing and handling its own component event.
Here is the component source.
Here is the client-side controller.
This simple example just logs the parameter passed to the method.
The <aura:method> tag set name="sampleMethod" and action="{!c.doAction}" so the method is called by cmp.sampleMethod() and handled by doAction() in the controller.
Using Inherited Methods
A sub component that extends a super component has access to any methods defined in the super component.
An interface can also include an <aura:method> tag. A component that implements the interface can access the method.