+ Start a Discussion
Tyler Morgan 9Tyler Morgan 9 

Separate input and output components

I'm trying to build two separate components for a home page. The first one will be a Rich Text input for a few assigned users to be able to enter a message on. The second component will be the output. I've built code to do this but I'm getting an error on function post:
Uncaught Action failed: c:parenttest$controller$post [Cannot read property 'setParams' of undefined]

I'm new to coding so I'm probably missing something simple.

Parent component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:registerEvent name="loadMyEvent" type="c:resultTest"/>
    <aura:attribute name="myVal" type="String" />
    <lightning:inputRichText value="{!v.myVal}" placeholder="Type message."/>
    <lightning:button label="Save" onclick="{!c.post}"/>

Parent JS:
    post : function(component, event, helper) {
        var evt = $A.get("e.c:restultTest");
        evt.setParams({ "Pass_Result": component.get("v.myVal")});

Child component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="Get_Result" type="String" />
    <aura:handler event="c:resultTest" action="{!c.getValueFromApplicationEvent}"/>
    The result is {!v.Get_Result}

Child JS:
    getValueFromApplicationEvent : function(cmp, event) {
        var ShowResultValue = event.getParam("Show_Result");
        // set the handler attributes based on event data
        cmp.set("v.Get_Result", ShowResultValue);

<aura:event type="APPLICATION">
    <aura:attribute name="Pass_Result" type="String"/>
Agustin BAgustin B
HI, check the name of evt on the JS
var evt = $A.get("e.c:restultTest"); it should be c:resultTest

if it helps please mark as correct, it may help others
Tyler Morgan 9Tyler Morgan 9
Thanks for the response.
I'm still getting the same error for setparams.
Agustin BAgustin B
HI Tyler, check this:https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_component_example.htm
Use the name, not the type of the event you registered.

if it solves your issue mark as correct so this can help others.
good luck