This post explains how to use custom labels in Lightning Component.
if your org not having any names space use default namespace 'c'
Example:
Lightning Component
Controller
Result:
Syntax
$Label.namespace.LabelNameif your org not having any names space use default namespace 'c'
Example:
Lightning Component
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="strLabelvalue" type="String" />
<!-- System handler -->
<aura:handler name="init" value="{!this}" action="{!c.getLabelValue}" />
<center>
<div class="slds-theme_default">
<!-- Custom Label value from component -->
<h2 class="slds-text-heading_medium slds-m-bottom_medium">Custom Label value from Lightning Component</h2>
<p><b>{!$Label.c.SalesforceCodeCrack}</b></p><br/><br/>
<!--Custom Label value from Controller -->
<h2 class="slds-text-heading_medium slds-m-bottom_medium">Custom Label value from Controller</h2>
<p><b>{!v.strLabelvalue}</b></p>
</div>
</center>
</aura:component>
Controller
({
getLabelValue : function(component, event, helper) {
var labelValue = $A.get("$Label.c.SalesforceCodeCrack");
component.set('v.strLabelvalue', labelValue);
},
})
Result:
No comments:
Post a Comment