{#each controller.content.assetAllocation.class}}
    {{@index}}
{{/each}}
I'm trying to run the code above, which is supposed to output the index of the array, but it produces an error saying: "Uncaught SyntaxError: Unexpected token , "
Solution is not as nice as I'd hoped, but this works:
{#each controller.content.assetAllocation.class}}
    {{_view.contentIndex}}
{{/each}}
                        Here's my way:
{#each controller.content.assetAllocation.class as |item index|}}
    {{index}} - {{item}}
{{/each}}
The index is Zero-based numbering. So if you want to change it, just add an helper like this:
Ember.Handlebars.registerBoundHelper("indexBase1", function (value, options) {
        return value + 1;
});
And using it:
{#each controller.content.assetAllocation.class as |item index|}}
    {{indexBase1 index}} - {{item}}
{{/each}}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With