shaunix
shaunix

Reputation: 667

Iterate over array in Ember Handlebars each

I have an object that I'm already iterating over to display the content in a template using handlebars {{#each}} - however, within each object there is an array that I also need to loop over.

Need to achieve something like.

{{#each item}}

  {{title}}
  {{rating}}

  {{#each array_field}}
    {{field}}
    {{anotherField}}
  {{/each}}

{{/each}}

Upvotes: 1

Views: 2023

Answers (1)

Ivan
Ivan

Reputation: 1100

You can create a pointer var to the current item, then query your array property:

{{#each item in controller}}
  {{item.title}}
  {{item.rating}}

  {{#each otherItem in item.arrayField}}
    {{otherItem.field}}
  {{/each}}

{{/each}}

Upvotes: 3

Related Questions