• charbel ALALAM
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
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 ?
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."+currentCat.name);   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:
 getLabel({
                    LabelName:labelReference, //labelreference is the name of custom label
                }).then(result=>{
                    
                    console.log('myJSON:'+result);
 
                }).catch(error=>{
                    console.log('error');
                })
//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 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."+currentCat.name);   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:
 getLabel({
                    LabelName:labelReference, //labelreference is the name of custom label
                }).then(result=>{
                    
                    console.log('myJSON:'+result);
 
                }).catch(error=>{
                    console.log('error');
                })
//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 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."+currentCat.name);   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:
 getLabel({
                    LabelName:labelReference, //labelreference is the name of custom label
                }).then(result=>{
                    
                    console.log('myJSON:'+result);
 
                }).catch(error=>{
                    console.log('error');
                })
//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