function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pramodh KumarPramodh Kumar 

lightning event is not getting fired in init method

I having a problem invoking the lightning event in the init method...

Here is my code please look into it
    <aura:registerEvent name="appEvent" type="c:aeEvent"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <h1>Simple Application Event Sample</h1>

/* aeNotifierController.js */
    doInit : function(cmp, event) {
        // Get the application event by using the
        // e.<namespace>.<event> syntax
        var appEvent = $A.get("e.c:aeEvent");
            "message" : "An application event fired me. " +
            "It all happened so fast. Now, I'm everywhere!" });;

    <aura:attribute name="messageFromEvent" type="String"/>
    <aura:attribute name="numEvents" type="Integer" default="0"/>

    <aura:handler event="c:aeEvent" action="{!c.handleApplicationEvent}"/>

    <p>Number of events: {!v.numEvents}</p>

/* aeHandlerController.js */
    handleApplicationEvent : function(cmp, event) {
        var message = event.getParam("message");

        // set the handler attributes based on event data
        cmp.set("v.messageFromEvent", message);
        var numEventsHandled = parseInt(cmp.get("v.numEvents")) + 1;
        cmp.set("v.numEvents", numEventsHandled);

<aura:application >