使用ng-include和ng-repeat的递归在第一级后不起作用

时间:2016-09-09 00:17:42

标签: javascript angularjs recursion ng-repeat angularjs-ng-include

我想递归一个对象来填充表格。

为此,我使用ng-includeng-repeat来通过对象并为每个新元素创建一个新的<tr>,但它在第一个级别后失败。

http://jsfiddle.net/Lsbect13/

1 个答案:

答案 0 :(得分:0)

您正在创建新数组而不是新对象。试试这个:

  "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"
    }]

it works!