How to get value from text box in Salesforce Lightning Component?

How to get value from text box in Salesforce Lightning Component?

Sample Code:


Lightning Component:

<aura:component implements=”forceCommunity:availableForAllPageTypes”>


    <aura:attribute name=”firstname”/>


    <ui:inputText label=”First Name” value=”{!v.firstname}”/>
    <ui:button label=”Register” press=”{!c.registerUser}”/>


</aura:component>

Lightning Component Controller:

({
registerUser : function(component, event, helper) {
            alert(component.get(“v.firstname”));
}
})

Leave a Reply