0

I want to build a clickable URL inside my lightning component as given below

<a aura:id="child321" 
   href="{!'/apex/viewAllRegionsVerticalHierarchyCR?id='+v.acco‌​untId1+'&Region='+it‌​em.key}"
>
   <h3>
      View all<br/>
      {!item.value} Children<br/>
      Of {!item.key} Region
   </h3>
</a>

But upon saving given ParseError is coming because of & character.I tried using escape character but with no avail. --The reference to entity "Region" must end with the ';' delimiter.

5
  • 1
    Can you provide your code? It will be easier to debug then Dec 16, 2016 at 12:35
  • Sorry I missed to give the desired URL :enter code here
    – Montosh
    Dec 16, 2016 at 12:36
  • Sorry I missed to give the desired URL :<a aura:id="child321" href="{!'/apex/viewAllRegionsVerticalHierarchyCR?id='+v.accountId1+'&Region='+item.key}"> <h3>View all<br/>{!item.value} Children<br/>Of {!item.key} Region</h3></a>
    – Montosh
    Dec 16, 2016 at 12:37
  • 1
    Please edit your post and type code there. Its highly unreadable in comments. Dec 16, 2016 at 12:39
  • Does the rendering work if you remove one variable? Dec 17, 2016 at 16:13

2 Answers 2

3

Maybe you can replace & by

&amp;

to have :

<a aura:id="child321" href="{!'/apex/viewAllRegionsVerticalHierarchyCR?id='+v.acco‌​untId1+'&amp;Region='+it‌​em.key}"> <h3>View all<br/>{!item.value} Children<br/>Of {!item.key} Region</h3></a>

This is the value to use in evaluable conditional expressions so maybe it's the same inside an expression string

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_operators.htm (Logical Operators paragraph)

1
0

Try to use an additional string attribute, compose it in the controller and inject it with a single href="{!yourAttrName}"

This will move the ampersand and it concatenation from markup to javascript and there it should work fine.

2
  • String constants work. E.g. <a href="{!'/' + v.value}">foo</a> is fine. This must be the case because lightning doesn't allow you to set part of an attribute value in an expression: <a href="/{!v.value}">foo</a> won't compile. The expression has to evaluate to the entire attribute value, so including string constants is a common pattern. Dec 17, 2016 at 16:16
  • @RobertSussland I modified my answer. Still I think it might be a viable approach worth to try
    – Uwe Heim
    Dec 18, 2016 at 6:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .