How to get number of iteration on Meteor {{#each}}?

854 views Asked by At

How can I get the index number of the {{#each}} list in Meteor? It seems like it should be really simple, but I can't find it.

1

There are 1 answers

2
Firdaus Ramlan On

Currently no build-in support for that. If you iterating cursor, use this:

return Collection.find().map(function (doc, index, cursor) {
  return _.extend(doc, {index: index + 1});
})

and use

{{#each .}}
  {{index}}
{{/each}}