'How to fetch the label from API name in Aura Component Controller
I have written a Apex class which return the list of objects in a String to be add in the drop down list in the AURA cmp Now I want to change the API name to label in the JS controller itself so is there any to fetch the Label from the API name.
doInit: function(component, event, helper) {
var action = component.get("c.getAllObjects");
var inputIndustry = component.find("InputAccountIndustry");
var opts=[];
action.setCallback(this, function(a) {
opts.push({
class: "optionClass",
label: "--- None ---",
value: ""
});
for(var i=0;i< a.getReturnValue().length;i++){
console.log(a.getReturnValue()[i]);
var labelReference = $A.getLabel("$Label.c.---" + a.getReturnValue()[i]);
console.log('label is ' + labelReference);
opts.push({"class": "optionClass", label: a.getReturnValue()[i], value: a.getReturnValue()[i]});
}
inputIndustry.set("v.options", opts);
});
$A.enqueueAction(action);
},
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
