1

Good afternoon everyone,

Now that custom labels are supported in Lightning. Has anyone had any success parameterizing them like the person did in this post? I'm trying to pass an attribute value as the label name.

Based on the post I tried the following syntax variations and cannot get it to work. I keep receiving a syntax error:

{!$Label.c.[v.labelname]} {!$Label[v.labelname]} {!$Label.[v.labelname]}

https://developer.salesforce.com/forums/?id=906F000000090OhIAI

2

Won't work right now.

  1. We don't support map[variable] de-referencing.

  2. Labels are going to be pre-parsed from the file to see what is necessary, and to do that it's essentially a regular expression $Label.(\w).(\w) -- (Note: not the actual regex) which we use to send down the labels with. If you have it as a variable we won't know which labels to send.

  3. If you did in fact have the label, you could do this in Javascript.

    $A.get("$Label." + cmp.get("v.labelname"));

2
  • 1
    Is it not possible to do map[variable] de-referencing at all in the markup currently? Not just with Custom Labels? If so, would there be an alternative way to get around that? – Daniel Fuller Aug 5 '15 at 17:56
  • Correct, no way to do it currently. you can do map["key"], but that just turns into map.key. – Kris Gray Aug 5 '15 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.