Hello friends today we will learn How to use Custom Label in Lightning Component(Aura Component). A custom label is a way to translate keywords in different-2 languages. We can directly use the custom label in Lightning component.
Use Custom Labels in Lightning Aura Component :
- $Label.c.labelName for the default namespace.
- $Label.namespace.labelName if your org has a namespace, or to access a label in a managed package.
check this also : Custom Label in visualforce Page
customLabelAura.cmp :
<aura:component implements="flexipage:availableForAllPageTypes">
<lightning:card title="{!$Label.c.WelcomeLabel}">
<p>
<lightning:button variant="brand" label="{!$Label.c.buttonlabel}" onclick=" {!c.clickLabel}"/>
</p>
</lightning:card>
</aura:component>
Use Custom Label in Javascript:
- $A.get(“$Label.c.labelName”) for the default namespace.
- $A.get(“$Label.namespace.labelName”) if your org has a namespace, or to access a label in a managed package.
customLabelAuraController.js :
({
clickLabel : function(component, event, helper) {
var label = $A.get("$Label.c.lableMessage");
alert(label);
}
})
What’s your Reaction?
+1
+1
+1
+1
+1
+1