ember.jshandlebars.jshtmlbars

get array element based on a property in emberjs template


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}}

Solution

  • 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