This is the JSON object that I'm passing to the page, its called "orders"
[
{
orderID: '5f69df7fb852e822bc1524e8',
customerName: 'John',
productIDs: [
'5f622bf4ee562b1d645ec09c',
'5f639ce70facd65c5c8e135e',
'5f69dddfd62fc74258103faa'
],
productNames: [ 'product1', 'product2', 'product3' ],
quantity: [ '1', '1', '1' ]
}
]
Example code:
{{#each orders}}
<form action="/edit/{{._id}}" method="post">
<label for="customerName">Customer's name</label>
{{! This works fine }}
<input type="text" value={{customerName}}>
<hr>
<p>Products:</p>
{{#each productNames}}
<label for="productNames">{{this}}</label>
{{! Here I want the value of "quantity" which has the same index as the product name }}
<input value="" type="number">
{{/each}}
</form>
{{/each}}
What I'm trying to achieve:
When I use a nested #each
, I get an error when trying to access the child array.