3

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}"/>
</aura:iteration>

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

3
  • 1
    does all the elements in list has asset-url populated ? This looks like a data issue Commented Jul 20, 2016 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
    Commented Jul 20, 2016 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. Commented Jul 20, 2016 at 23:23

1 Answer 1

3

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

You must log in to answer this question.

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