function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
charbel ALALAMcharbel ALALAM 

how to get a reference to custom label in lwc dynamically

hi guys, 
i have a question plz:
How can i get a reference to a custom label dynamically using lwc:
i have this code and i want to convert it to lwc:
var currentCat = categoryWrapper.categories[i];  var labelReference = $A.getReference("$Label.c.";   component.set("v.tempLabel", labelReference);
//we can't use $A.getreference in lwc,
 and using apex i didn't found a solution 
this is the function in apex:
 @AuraEnabled     public static String getLabel(String LabelName){                  system.debug('LabelName'+LabelName);  
      String s2 = system.Label.LabelName ;  return s2;     }
this is the function in lwc:
                    LabelName:labelReference, //labelreference is the name of custom label
//i want to return the value of a custom label when i send the name of custom label in parameter. Where Is my error, and is there a solution ?
Best Regards

Hi Charbel,

Please check with below link for accessing label in LWC

Once you get the label, you can rendered it based on the requirement.


Hope this helps,

Rajendra Singh NagarRajendra Singh Nagar
I also faced similar restrictions and has worked on a service utility. Refer below:
Neel Kamal 6Neel Kamal 6

Please upvote on idea exchang