Here a function takes 3 parameters
- Component – Represents the component to which the controller belongs
- Event – The event that action is handling. Like a click event or select event etc.
Component attributes value can be accessed in controller section by using syntax shown below.
var a_attribute_Value = component.get("v.a_Attribute_Name");
var a_String_Value = component.get("v.a_String");
A new value can be set to attributes that are declared in component with below syntax.
“New_Value” should be of specific data type and double quotes may or may not be required as per data used (Data in a variable and raw data).
component.set("v.a_String","A new string value"); component.set("v.a_Integer",21);
- Means, If you write function(a, b, c), then a is component reference, b is event reference and c is helper reference. It is wise to choose proper name to avoid confusion.
- Everything in Controller and Helper is case-sensitive.
- A controller is in lightning bundle is saved as componentNameController.js. if you component name is My_Lightning_Component, then a controller will be saved as My_Lightning_ComponentController.js.