I want to recurse an object to populate a table.
我想递归一个对象来填充一个表。
For this, I am using ng-include
and ng-repeat
to go thru the object and create a new <tr>
for each new element but it fails after the first level.
为此,我使用ng-include和ng-repeat来通过对象并为每个新元素创建一个新的但它在第一个级别后失败。
1 个解决方案
#1
0
You're creating new arrays rather than new objects. Try this instead:
您正在创建新数组而不是新对象。试试这个:
"nodes": [{
"name": "Level 1",
"att1": "att1-level1",
"att2": "att2-level1"},
{"name": "Level 2",
"att1": "att1-level2",
"att2": "att2-level2"},
{
"name": "Level 3A",
"att1": "att1-level3a",
"att2": "att2-level3a"}
, {
"name": "Level 3B",
"att1": "att1-level3b",
"att2": "att2-level3b"
}]
#1
0
You're creating new arrays rather than new objects. Try this instead:
您正在创建新数组而不是新对象。试试这个:
"nodes": [{
"name": "Level 1",
"att1": "att1-level1",
"att2": "att2-level1"},
{"name": "Level 2",
"att1": "att1-level2",
"att2": "att2-level2"},
{
"name": "Level 3A",
"att1": "att1-level3a",
"att2": "att2-level3a"}
, {
"name": "Level 3B",
"att1": "att1-level3b",
"att2": "att2-level3b"
}]