The index operator in the steering wheel says that an unexpected token,

I have a #each loop in my ember application and want to know the loop index, so I am trying to use {{@index}} as follows:

<script type="text/x-handlebars" data-template-name="column"> <ul> {{#each item in controller}} {{@index}} {{item-rows currentItem=item}} {{/each}} </ul> </script> 

But in chrome, I get this error:

 Uncaught SyntaxError: Unexpected token , handlebars.js:1457 

My version of ember.js is rc8 and handlebars is 1. I need a solution to find the #each index.

+4
source share
1 answer

You can get contentIndex from itemViewClass helper #each

 {{#each itemViewClass="Em.View"}} <h3 class="row">{{name}} - <small>{{view.contentIndex}}</small></h3> {{/each}} 

DEMO FIDDLE

+4
source

Source: https://habr.com/ru/post/1500246/


All Articles