I want to put the serial no. in the table inside the #each loop, In the .hbs file I tried this:
{{#each item}}
<tr>
<th>{{@index}}</th>
<tr>
{{/each}}
But this prints the index from 0, I want to start it from 1, How do I do it?
I want to put the serial no. in the table inside the #each loop, In the .hbs file I tried this:
{{#each item}}
<tr>
<th>{{@index}}</th>
<tr>
{{/each}}
But this prints the index from 0, I want to start it from 1, How do I do it?
a helper function that lets you perform calculations on expressions like addition and subtraction etc.
Below function registers a new helper, which simply increments a value by 1:
var Handlebars = require('handlebars');
Handlebars.registerHelper("addOne", function(value, options)
{
return index + 1;
});
You can then use it within the handlebar expression using the addOne keyword, like:
{{addOne @index}}