2

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); } }) 
1
  • Thanks found the err ({ 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); }) Commented Jun 15, 2017 at 9:42

2 Answers 2

4

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.

0
0

The bug is at Component.find("Type").set("v.options",types); . Because Lightning component is case sensitivity .

Instead use same case as you mentioned above component.find("Type").set("v.options",types);

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.