Im trying to iterate an Array of Objects for putting their values in a Handlebars template using the each loop inside the structure of the array. Here you can see the array:
var datosSensores = [ { name:'John Pinard', email:'jp@aol.com', ph: [ '7.80', '7.90', '7.60', fecha: [ '2016-06-20 09:00', '2016-06-21 10:00' ], ], } ];
And the each loop if've tried as you can see:
{{#each ph}} .... ..... {{#each ph.fechaPH}} {{this.fechaPH}} //This would be the value of each DATE in the array {{/each}} {{/each}}
I dont know how to solve it or what I'm doing wrong. I appreciate any comment about this issue Thanks a lot!
You're almost using the correct syntax :
{{#each ph}}
....
.....
{{#each fecha}}
{{this}} //This would be the value of each DATE in the array
{{/each}}
{{/each}}
When you're inside a #each loop the this object becomes the "root" node so you don't need to name ph.fecha but just fecha as ph is the root.
[Edit] : I've changed the name fechaPH does not exist in your example it is fecha.
{#each main}}
{{#each sub}}
<p>{{ ../dataOfMain }}</p>
<p>{{ subData }}</p>
{{/each}}
{{/each}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.