Reputation: 667
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
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