Reputation: 4881
I am struggling to see how to use Handlebars with simple string arrays. I have the following object
When looping around the searchParam array I use something like :
{{#each model.searchParam}}
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="th-narrow">Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="label">name</span></td>
<td>{{name}}</td>
</tr>
<tr>
<td><span class="label">type</span></td>
<td>{{type}}</td>
</tr>
</tbody>
</table>
{{/each}}
In the image above, how do I loop around the "searchInclude" array?
{{#each model.searchInclude}}
... wht do I reference here for the contents of the array?
{{/each}}
Upvotes: 1
Views: 219
Reputation: 9989
In case of an array, this
will be the value and you can obtain the index with the Handlebar magic keyword @index
{{#each model.searchInclude}}
{{@index}}: {{this}}
{{/each}}
Upvotes: 1