Reputation: 13721
I am building an app using node.js + handlebars. My server sends two objects to my view: users
and companies
. My users load fine, but for some reason my companies will not populate my dropdown list:
{{#each users}}
<tr>
<td id="id">{{id}}</td>
<td>{{first_name}}</td>
<td>{{email}}</td>
<td><button type="button" class="btn btn-primary" id="confirm">Confirm</button></td>
<td><button type="button" class="btn btn-primary" id="disable">Disable</button></td>
<td><button type="button" class="btn btn-danger" id="delete">Delete</button></td>
<td><button type="button" class="btn btn-primary" id="view">View</button></td>
<td>
<select id="company" class="form-control">
{{#each companies}}
<option>{{company_id}}</option> <!-- This will not populate -->
{{/each}}
</select>
</td>
</tr>
{{/each}}
Anyone know what might be going on?
As a side note, if I try to render my companies
outside of the table, it works. For example:
{{#each companies}}
<p>{{company_id}}</p>
{{/each}}
Thanks!
Upvotes: 1
Views: 32
Reputation: 4604
From what you describe 'companies' is at the top scope. Use {{#each ../companies}}.
Upvotes: 2