How to get Salesforce Lightning event label to controller?
The below code is a sample component, is having one attribute for message, and has 2 lightning buttons.
Wants to display the button label on Lighting component.
<aura:component>
<aura:attribute name="message" type="String"/>
<p>Message of the day: {!v.message}</p>
<div>
<lightning:button label="You look nice today."
onclick="{!c.handleClick}"/>
<lightning:button label="Today is going to be a great day!"
onclick="{!c.handleClick}"/>
</div>
</aura:component>
Controller:
({
handleClick: function(component, event, helper) {
var btnClicked = event.getSource(); // the button
var btnMessage = btnClicked.get("v.label"); // the button's label
component.set("v.message", btnMessage); // update our message
}
})
Component Displays:
The below code gets Button
var btnClicked = event.getSource(); // the button
The below code gets Button label
var btnMessage = btnClicked.get("v.label"); // the button's label
The below code updates the attribute named "message"
component.set("v.message", btnMessage); // update our message
Source: trailhead.salesforce.com
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteDotnet Training in Marathahalli
I wish to show thanks to you just for bailing me out of this particular trouble.As a result of checking through the net and meeting techniques that were not productive, I thought my life was done.
ReplyDeleteAWS Training in Bangalore