Is it possible to make id with expression and literal string?

Like if I have an attribute called ownerId and I want the div to have id="ownerIdvalue+appendedString"

For example, if my ownerId value is 345ABC and the div id to have a string 'New' following the ownerIdvalue. I know I can make the div id to be the same as the attribute value by <div id='{!v.ownerId}', but not sure how to make the div id to be '345ABCNew'.



I figured it out after multiple times modifying the id. This works

 <div id="{!'New' + v.ownerId}"></div>
| improve this answer | |

You can make whatever "id" you want for non-managed elements, including from merge fields. This is acceptable:

<div id="{!owner.name}{!somevalue}">...

For managed elements-- those that start with a namespace like apex or c, you must use literal values.

| improve this answer | |
  • that syntax doesn't work for some reasons. I got it to work by using <div id="{!'New' + v.ownerId}"></div> – zeo2396 Jun 24 '15 at 19:12

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.