You need to sign in to do that
Don't have an account?
Javascript Lightning Trailhead Challenge - non developer needs help
I'm not a developer so I'm really trying to work through this challenge and can't figure this out.
I am getting the following error: The client side controller does not have a 'calculate' method when trying to figure out the Using Javascript with Components Lightning Trailhead module.
Here is the challenge:
Your company needs an interface that shows a calculation based on three inputs. The correct value must be the addition of the first two inputs and subtraction of the third. Create a form and client side controller to calculate the total.The component must be named 'CalculateTotal'.
-The component should have three aura:inputNumber components with ID's 'inputOne', 'inputTwo', and 'inputThree'.
-The total must be displayed using a aura:outputNumber component with the ID 'totalValue'
-The client-side controller must do the calculation in a method named 'calculate'.
-The client-side controller can use the standard JavaScript function parseInt to enforce the data type.
-The component must invoke the 'calculate' method on the client-side controller to perform the calculation.
Here is my component:
<aura:component >
<form>
<fieldset>
Enter three values:<br/>
<ui:inputNumber aura:Id="inputOne" value="{!v.inputOne}"/><br/>
<ui:inputNumber aura:Id="inputTwo" value="{!v.inputTwo}"/><br/>
<ui:inputNumber aura:Id="inputThree" value="{!v.inputThree}"/><br/>
<ui:button label="Submit" press="{!c.calculate}"/><br/>
<ui:outputNumber aura:id="totalValue" value="{!v.totalValue}"/><br/>
</fieldset>
</form>
</aura:component>
Here is my controller:
({
calculate: function(component, item, callback) {
component.find("inputOne").get("v.inputOne");
component.find("inputTwo").get("v.inputTwo");
component.find("inputThree").get("v.inputThree");
var action = component.get("c.calculateTotal");
var this.totalValue = InputOne + InputTwo -InputThree;
InputOne = parseInt({!v.InputOne});
InputTwo = parseInt({!v.InputTwo});
InputThree = parseInt({!v.InputThree});
action.setCallback(this,function(a) {
component.set("v.totalValue",a.getReturnValue());
});
$A.enqueueAction(action);
},
})
}
I am getting the following error: The client side controller does not have a 'calculate' method when trying to figure out the Using Javascript with Components Lightning Trailhead module.
Here is the challenge:
Your company needs an interface that shows a calculation based on three inputs. The correct value must be the addition of the first two inputs and subtraction of the third. Create a form and client side controller to calculate the total.The component must be named 'CalculateTotal'.
-The component should have three aura:inputNumber components with ID's 'inputOne', 'inputTwo', and 'inputThree'.
-The total must be displayed using a aura:outputNumber component with the ID 'totalValue'
-The client-side controller must do the calculation in a method named 'calculate'.
-The client-side controller can use the standard JavaScript function parseInt to enforce the data type.
-The component must invoke the 'calculate' method on the client-side controller to perform the calculation.
Here is my component:
<aura:component >
<form>
<fieldset>
Enter three values:<br/>
<ui:inputNumber aura:Id="inputOne" value="{!v.inputOne}"/><br/>
<ui:inputNumber aura:Id="inputTwo" value="{!v.inputTwo}"/><br/>
<ui:inputNumber aura:Id="inputThree" value="{!v.inputThree}"/><br/>
<ui:button label="Submit" press="{!c.calculate}"/><br/>
<ui:outputNumber aura:id="totalValue" value="{!v.totalValue}"/><br/>
</fieldset>
</form>
</aura:component>
Here is my controller:
({
calculate: function(component, item, callback) {
component.find("inputOne").get("v.inputOne");
component.find("inputTwo").get("v.inputTwo");
component.find("inputThree").get("v.inputThree");
var action = component.get("c.calculateTotal");
var this.totalValue = InputOne + InputTwo -InputThree;
InputOne = parseInt({!v.InputOne});
InputTwo = parseInt({!v.InputTwo});
InputThree = parseInt({!v.InputThree});
action.setCallback(this,function(a) {
component.set("v.totalValue",a.getReturnValue());
});
$A.enqueueAction(action);
},
})
}
I have recently cleared this module and following code worked for me so please go through this and compare it with your code.
Component
Controller
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
All Answers
I have recently cleared this module and following code worked for me so please go through this and compare it with your code.
Component
Controller
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Component:
Controller: