A component registers that it may fire an event by using <aura:registerEvent> in its markup. For example:
<aura:registerEvent name="sampleComponentEvent" type="c:compEvent"/>
We’ll see how the value of the name attribute is used for firing and handling events.
To get a reference to a component event in JavaScript, use cmp.getEvent("evtName") where evtName matches the name attribute in <aura:registerEvent>.
Use fire() to fire the event from an instance of a component. For example, in an action function in a client-side controller:
var compEvent = cmp.getEvent("sampleComponentEvent"); // Optional: set some data for the event (also known as event shape) // A parameter’s name must match the name attribute // of one of the event’s <aura:attribute> tags // compEvent.setParams({"myParam" : myValue }); compEvent.fire();