0

I have an array someArray and I try to get its nth element, where n based on row's property.

{{#each data as |row|}}
  {{someArray.[row.property]}}
{{/each}}
user3568719
  • 1,036
  • 15
  • 33

2 Answers2

3

Ember.js' HTMLBars has a get helper that you can use. It doesn't support integer indices, but if you convert it to a string, with the clever use of concat, it should work:

{{#each data as |row|}}
  {{get someArray (concat row.property)}}
{{/each
locks
  • 6,537
  • 32
  • 39
0

Handlebars has a lookup helper:

{{#each data as |row|}}
    {{lookup ../someArray row.property}}
{{/each}}
76484
  • 8,498
  • 3
  • 19
  • 30
  • I'd like to note that the question is tagged `ember.js`, and `lookup` isn't defined there. – locks May 09 '16 at 00:47