You need to sign in to do that
Don't have an account?
charbel ALALAM
how to get a custom label dynamically in lwc,
Hello guys,
i have a question plz,
how can i get custom label dynamically in lwc,
i have this code in aura and i'm migrating it to lwc:
//aura:
var currentCat = categoryWrapper.categories[i];
var labelReference = $A.getReference("$Label.c."+currentCat.name);
component.set("v.tempLabel", labelReference);
In lwc we can't use $A, or the same function,
we can import the name of custom label and then use the custom label, but it's static. What i want is to get the custom label dynamically,
for example, the value of currentCat.name=B2B_CUL_Textile (name of custom label) the vat of label reference is the value of the custom label (Textile).
we can't use apex because it dosen't work, and i want it in lwc only not in vf, Is there any idea ?
i have a question plz,
how can i get custom label dynamically in lwc,
i have this code in aura and i'm migrating it to lwc:
//aura:
var currentCat = categoryWrapper.categories[i];
var labelReference = $A.getReference("$Label.c."+currentCat.name);
component.set("v.tempLabel", labelReference);
In lwc we can't use $A, or the same function,
we can import the name of custom label and then use the custom label, but it's static. What i want is to get the custom label dynamically,
for example, the value of currentCat.name=B2B_CUL_Textile (name of custom label) the vat of label reference is the value of the custom label (Textile).
we can't use apex because it dosen't work, and i want it in lwc only not in vf, Is there any idea ?
Please check out below thread to understand how you can achieve this requirement:
https://rajendrasnagar.wordpress.com/2020/11/20/use-custom-labels-dynamically-in-lwc/
Hope above information helps. Please mark as Best Answer so that it can help others in future.
Thanks.
The point of non-dynamic labels is to provide compile-time safety of labels, and prevent deletion/renaming of labels that would otherwise break code.
As such, there's no real support for dynamic labels in LWC. There's no known timeline when, or if, this might become available.
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh