[SalesForce] Component is not defined Error in Lightning application

Hi Am getting started with SPAs using Lightning Application am kind off stuck with the below error:

This page has an error. You might just need to refresh it. Action
failed: c:newRace$controller$doit [Component is not defined] Failing
descriptor: {c:newRace$controller$doit}

.app file

<aura:application >
 <aura:attribute name="name" type="String" />
 <aura:attribute name="races" type="String[]" default="['Race 1','Race 2','Race 3']" />
     <aura:handler name="init" value="{!this}" action="{!c.doit}" />
    <div>
    <h1>Enter New Race</h1>
        <ui:inputText label="name" aura:id="name" value="{!v.name}" />
        <ui:inputSelect label="Race Type" aura:id="Type" />
        <ui:inputDate label="Race Date" aura:id="DateTime" />
        <ui:inputTextArea label="Location" aura:id="Location" />
        <ui:inputcheckbox label="Attended?" aura:id="Attended" />
        <ui:inputText label="Results" aura:id="Results" />
        <ui:button label="Submit" press="{!v.NewRace}" />
    </div>   

 <div>
         <aura:iteration items="{!v.races}" var="race">
             <ui:outputText value="{!race}"/> <br/>
    </aura:iteration>
    </div>
</aura:application>

Controller

({
    doit: function(component, event, helper) {
        var types= [{class:"OptionClass", label:"5k", value:"5k"},
                    {class:"OptionClass", label:"10k", value:"10k"},
                    {class:"OptionClass", label:"Half-Marathon", value:"Half-Marathon"}];

                     Component.find("Type").set("v.options",types);
    }
})

Best Answer

Contrary to Apex, Javascript is case sensitive.

You have a typo in your doit method. You have to use component instead of Component because the variable you defined as argument is called component too.

Related Topic