ngRepeat无法遍历嵌套数组

时间:2014-02-10 12:53:49

标签: javascript angularjs angularjs-ng-repeat

我想访问我的数组数组的每个值:

[
 ["0","0","0"],
 ["1","1","1"],
 ["1","0","0"]
]

我在

中只做了两次ngRepeat
<ul>
  <li ng-repeat="line in test">
  {{line}}
    <ul>
      <li ng-repeat="point in line">
        {{point}}
      </li>
    </ul>
  </li>
</ul>

这可能是愚蠢的事,但我无法弄明白。

这里是plunk: http://plnkr.co/edit/LeZw0HRab472dcNiHPQM?p=preview

1 个答案:

答案 0 :(得分:4)

我认为您正在寻找的是:

<ul>
      <li ng-repeat="line in test">

        <ul>
          <li ng-repeat="point in line track by $index">
            {{point}}
          </li>
        </ul>
      </li>
    </ul>

http://plnkr.co/edit/72a1Brmn2eBuTWhI8pfC?p=preview