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}}
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
Handlebars has a lookup helper:
{{#each data as |row|}}
{{lookup ../someArray row.property}}
{{/each}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.