问题
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!
回答1:
You're using almost 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.
来源:https://stackoverflow.com/questions/44805977/nested-each-loops-with-handlebars-template