Passing parameters from Lightning Component to Controller and Controller to Component

In this example to learn about to pass parameters from Lightning component to controller vice versa

By using component.get(v.attributeName) or  component.find(“aura:id”).get(“v.value”) ->pass value from Lightning Component to Controller.
By using component.set(“v.attributeName”,value);  -> pass value from Controller to Lightning Component.

Component:

<aura:component >
    <aura:attribute name="employeeName" type="String"/>
    <ui:inputText label="Enter Employee Name"  aura:id="name" />
    <ui:button label="submit" press="{!c.callme}" /> <br />
    Employee Name Entered:  <ui:outputText value="{!v.employeeName}" />
</aura:component>

Controller.js
({
    callme : function(component, event, helper) {
    var EmployeeName = component.find("name").get("v.value");
    component.set("v.employeeName",EmployeeName)
    }
})

(883)

Written by 

I am Sakthivel Madesh, a certified Salesforce Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 13x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply