Positional index in Ember.js collections iteration

It’s old question but still gets a lot of hits. In the current version of Ember.JS one can use _view.contentIndex to display current index inside the loop.

    Index: {{_view.contentIndex}}

If you need an adjusted index (for instance starting from 1) then there is a possibility of creating reusable helper increment

Ember.Handlebars.registerBoundHelper('increment', function(integer) {
    return integer + 1;

then you would use it in the following way

    Index: {{increment _view.contentIndex}}


Starting with ember 1.11 you can do as well

{{#each people as |person index|}}
   Index: {{increment index}}

Leave a Comment