You need to sign in to do that
Don't have an account?
Louis Nguyen
Trailhead: The 'PhoneNumberInput' client-side controller is not setting the phone param
Hi,
I keep getting this error when trying to do a Trailhead Challenge. Any ideas? Thanks.
Here is my code:
PhoneNumberEvent.evt
I keep getting this error when trying to do a Trailhead Challenge. Any ideas? Thanks.
Here is my code:
PhoneNumberEvent.evt
<aura:event type="APPLICATION" description="Event template"> <aura:attribute name="phone" type="String"/> </aura:event>MyApplication.app
<aura:application > ({ send : function(component, event, helper) { var phone = component.find("phone").get("v.value"); console.log(phone); $A.get("event.c:PhoneNumberEvent").setParams({ phone: phone }).fire(); } }) ({ answer : function(component, event, helper) { var text = event.getParam("phone"); component.set("v.phone", text); } }) <c:PhoneNumberInput/> <c:PhoneNumberOutput/> </aura:application>PhoneNumberInput.cmp
<aura:component > <aura:registerEvent name="PhoneNumberEvent" type="c:PhoneNumberEvent"/> <ui:inputPhone aura:id="phone" label="phone" /> <ui:button label="Show Phone" press="{!c.send}"/> </aura:component>PhoneNumberOutput.cmp
<aura:component > <aura:attribute name="phone" type="String" default="No Phone Number"/> <ui:outputText aura:id="phone" value="{!v.phone}"/> <aura:handler event="c:PhoneNumberEvent" action="{!c.answer}"/> </aura:component>
I believe the JavaScript in your MyApplication.app needs to be placed in the PhoneNumberInputController.js and PhoneNumberOutputController.js controller. Your app should just have:
Your PhoneNumberInputController.js should have send function. You can access the controller by selecting it from the nav on the right when the component is open:
Similarly, your answer function should be placed in the PhoneNumberOutputController.js
All Answers
I believe the JavaScript in your MyApplication.app needs to be placed in the PhoneNumberInputController.js and PhoneNumberOutputController.js controller. Your app should just have:
Your PhoneNumberInputController.js should have send function. You can access the controller by selecting it from the nav on the right when the component is open:
Similarly, your answer function should be placed in the PhoneNumberOutputController.js
Here is the code mentioned above for the Phone Number Input Controller