You need to sign in to do that
Don't have an account?
Bvenkat Jeewesh(Dev)
How to get value from Helper.js to Controller.js in Lightning Component
How to get value from Helper.js to Controller.js in Lightning Component
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
The Simplest way to get value from helper to controller is to create an aura attribute in component and set value of the particular attribute in
Helper. Then you can get value of that attribute in your controller.
For Example:
In Component you need to add:
<aura:attribute name="myAttribute" type="String"/>
In Helper you need to add:
c.set("v.myAttribute",'Demo');
In Controller you can get value by this:
var myValue=c.get("v.myAttribute");
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Greetings to you!
- You can use an attribute for lightning to get and set the value, which helps you to get value from Helper.js to Controller.js in Lightning Component
- First, you have to make an attribute on the lightning component.
<aura:attribute name="name" type="String" access="global"/>
- Then in Helper.js, you have to set the value in attribute 'name'.
component.set('v.name','Bob');
- Then in Controller.js, you can get the value of attribute 'name'.
let valueOfName = component.get('v.name');
- To check the value you can use : - console.log('valueOfName-->'+valueOfName);
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.