Based on this How to split array dynamically based on single value in JavaScript Node.js i created object with Arrays, and i can display name of each array by this:
- each item in Object.keys(groupedData)
li= item
result is:
* Fruit
* Sport
* Kitchen
However how can I display value of each array in diffrent tables? eg.
I don't know how to take any value from array?
I thought about this li= item.array[0].tag
but it doesn't work.
@EDIT
If I use:
- each val, key in groupedData
li #{JSON.stringify(val)}
I can display values, result at view:
[{"name":"Apple","tag":"Fruit","price": 2},
{"name":"Kiwi","tag":"Fruit","price": 1}]
But how can i put this to table?
答案 0 :(得分:0)
Here's a small example that you can see working in this codepen
- var groupedData = {'X': [{'a': 'x0', 'b': 'x1'},{'a': 'xx0', 'b': 'xx1'}], 'Y': [{'a': 'y0', 'b': 'y1'},{'a': 'yy0', 'b': 'yy1'}], 'Z': [{'a': 'z0', 'b': 'z1'},{'a': 'zz0', 'b': 'zz1'}]}
- each grp in Object.keys(groupedData)
h1= grp
table
thead
- each val, index in groupedData[grp][0]
th= index
- each subgrp in groupedData[grp]
tr
- each val in subgrp
td= val