0

Error

ChildCompo:-

     <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="firstName" type="String" />
    <aura:registerEvent name="contactDataEvent" type="c:ChildParentEvent"/>     
    
    <lightning:input 
                     aura:id="input1"
                     type="text"
                     name="input2" 
                     label="First Name"
                     value="{!v.firstName}"
                     onchange="{!c.searchKeyChange}"
                     placeholder="Search"/>   <br />  
          </aura:component>

ChildController:-

     ({
          searchKeyChange : function(component, event, helper) {
        var cmpEvent = component.getEvent("ChildParentEvent");
        cmpEvent.setParams({"firstName" : component.find('input1').get('v.value')});
        cmpEvent.fire();
        alert('Event fired');
        console.log("cmpEvent Event Fired");
       } 
    })

ParentCompo:-

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="receivedFromChild" type="String" />
    
    <aura:handler name="contactDataEvent" event="c:ChildParentEvent" action="{!c.receiveDataController}"/>     
    
    <div class="slds-m-around_xx-large">
        <c:childCompo /> <br />
        Received value from Child = <ui:outputText value="{!v.receivedFromChild}" />
    </div>
    
</aura:component>

ParentController:-

   ({
         receiveDataController : function(component, event, helper) {    
         var receivedData = event.getParam("firstName");  
         console.log("Received from Child = ", receivedData);
         component.set('v.receivedFromChild' , receivedData);     
      }
    })

ChildParentEvent:-

     <aura:event type="COMPONENT" description="Event template" >
     <aura:attribute name="firstName" type="String" />
     </aura:event>
4
  • @PhilW Please fix this code.
    – Crazy XYZ
    Commented Dec 28, 2022 at 6:11
  • @KrisGoncalves Please fix this code.
    – Crazy XYZ
    Commented Dec 28, 2022 at 6:12
  • @sanketkumar Please fix this code.
    – Crazy XYZ
    Commented Dec 28, 2022 at 6:13
  • Looking at the code statically I cannot see anything that jumps out (perhaps other than the alert call). Have you tried to debug the processing via the browser's inspector?
    – Phil W
    Commented Dec 28, 2022 at 8:25

0

You must log in to answer this question.