[SalesForce] aura:handler has invalid name attribute value:

I'm going through the Salesforce Trailhead Module on Lightning Components and I'm on the section for Handling Events with Client Side Controllers. I'm copying the Component Event example and when saving the component that is supposed to be handling an event I get the following error.

Failed to save undefined: aura:handler has invalid name attribute value: trailheadMessage1: Source

This component is named "trailheadReceiver.cmp" and code is as follows

<aura:component >
    <aura:attribute name="myText" type="String" default="None" />    
    <aura:handler name="trailheadMessage1" action="{!c.answer1}" />

    <c:trailheadSender />
    Message: {!v.myText}
</aura:component>

My event component is named "trailheadMessage1.evt" and the code is as follows:

<aura:event type="COMPONENT" description="Event template" >
    <aura:attribute name="text1" type="String" />
</aura:event>

My component that is generating the event is named "trailheadSender.cmp" and the code is as follows:

<aura:component >    
    <aura:registerEvent name="trailheadMessage1" type="c:trailheadMessage1" />
    <ui:button label="1" press="{!c.send1}" />
    <ui:button label="2" press="{!c.send1}" />
</aura:component>

The name I'm using in my handler matches the name of the event component, as well as the name I've put in the tag. I've tried adding the event attribute to the tag, but I get an error saying that it can only have the name of event attributes, but not both. I've tried using the event attribute only, but then it complains that is only for APPLICATION events.

I can't figure out why I'm getting this error, or how to fix it.

Best Answer

Try changing:

<c:trailheadSender />

to

<c:trailheadSender trailheadMessage1="{!c.answer1}" />

and remove:

<aura:handler name="trailheadMessage1" action="{!c.answer1}" />