We’re rewarding the question askers & reputations are being recalculated! Read more.
2 added 163 characters in body
source | link

In VisualForce we could access dynamically to map elements using syntax

{!map[mapIndex]}

In Lightning if we try to define a map and use this syntax we would receive an error saying

Failed to save undefined: expecting a positive integer, found 'mapIndex' at column 9 of expression: (v.map[mapIndex]) : Source

Which means that Lightning doesn't understand how to process maps and objects dynamically in Javascript. However, in pure javascript it is not a problem to access map or object member dynamically.

Is there any way to avoid this restriction?

Update: I am looking for some solution which wouldn't require javascript. I am looking for solution which would use only native syntax of Lightning Component.

In VisualForce we could access dynamically to map elements using syntax

{!map[mapIndex]}

In Lightning if we try to define a map and use this syntax we would receive an error saying

Failed to save undefined: expecting a positive integer, found 'mapIndex' at column 9 of expression: (v.map[mapIndex]) : Source

Which means that Lightning doesn't understand how to process maps and objects dynamically in Javascript. However, in pure javascript it is not a problem to access map or object member dynamically.

Is there any way to avoid this restriction?

In VisualForce we could access dynamically to map elements using syntax

{!map[mapIndex]}

In Lightning if we try to define a map and use this syntax we would receive an error saying

Failed to save undefined: expecting a positive integer, found 'mapIndex' at column 9 of expression: (v.map[mapIndex]) : Source

Which means that Lightning doesn't understand how to process maps and objects dynamically in Javascript. However, in pure javascript it is not a problem to access map or object member dynamically.

Is there any way to avoid this restriction?

Update: I am looking for some solution which wouldn't require javascript. I am looking for solution which would use only native syntax of Lightning Component.

    Tweeted twitter.com/StackSalesforce/status/889027153723043840
1
source | link

How to access map or object elements dynamically in Lightning?

In VisualForce we could access dynamically to map elements using syntax

{!map[mapIndex]}

In Lightning if we try to define a map and use this syntax we would receive an error saying

Failed to save undefined: expecting a positive integer, found 'mapIndex' at column 9 of expression: (v.map[mapIndex]) : Source

Which means that Lightning doesn't understand how to process maps and objects dynamically in Javascript. However, in pure javascript it is not a problem to access map or object member dynamically.

Is there any way to avoid this restriction?