I am using aura:iteration to iterate and show images on my lightning component. Which looks like below:

<aura:iteration items="{!v.Assets}" var="asset">
  <img src="{!asset.asset-url}"/>

For some reason, the aura expressions can't evaluate asset-url and return NaN. Am I doing something wrong here? It works if I do asset_url

  • 1
    does all the elements in list has asset-url populated ? This looks like a data issue Jul 20 '16 at 23:10
  • Yeah, it does. Conventionally, I believe it should be asset_url. I was hoping aura could do something like {!asset['asset-url'}
    – kev_panda
    Jul 20 '16 at 23:15
  • 3
    I'm pretty sure you'll have to rename your asset-url var - I read somewhere that - chars aren't allowed in this syntax... can't remember where though. Jul 20 '16 at 23:23

Hyphens are not allowed when declaring a variablle. I suggest you to rename the variable with underscore.

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.