ng-repeat不在第三个循环上工作

时间:2017-02-13 20:39:32

标签: javascript angularjs json

ng-repeat不能在第三个循环(第三级)上工作

    <div ng-repeat="child in jdata.children">
        <div ng-repeat="childsub in child.children">
            <div ng-repeat="text in childsub.text">
              {{ text.value}}
            </div>
        </div>
    </div>
第三个循环上的

无法正常工作

JSON数据(plunker link)如下

{
  "children": [
    {
      "type": "layer",
      "visible": true,
      "opacity": 1,
      "blendingMode": "normal",
      "name": "border",
      "left": 0,
      "right": 320,
      "top": 0,
      "bottom": 50,
      "height": 50,
      "width": 320,
      "mask": {},
      "image": {}
    },
    {
      "type": "group",
      "visible": false,
      "opacity": 1,
      "blendingMode": "normal",
      "name": "Frame 1",
      "left": -26,
      "right": 338,
      "top": 0,
      "bottom": 182,
      "height": 182,
      "width": 364,
      "childrens": [
        {
          "type": "layer",
          "visible": true,
          "opacity": 1,
          "blendingMode": "normal",
          "name": "Savings that will make you smile like Barney",
          "left": 117,
          "right": 290,
          "top": 7,
          "bottom": 44,
          "height": 37,
          "width": 173,
          "mask": {},
          "text": {
            "value": "Savings that will make\ryou smile like Barney",
            "font": {
              "name": "VAGRoundedStd-Bold",
              "sizes": [
                13,
                13,
                13,
                13,
                13
              ],
              "colors": [
                [
                  91,
                  64,
                  142,
                  255
                ],
                [
                  91,
                  64,
                  142,
                  255
                ],
                [
                  91,
                  64,
                  142,
                  255
                ],
                [
                  236,
                  0,
                  140,
                  255
                ],
                [
                  91,
                  64,
                  142,
                  255
                ]
              ],
              "alignment": [
                "center",
                "center"
              ]
            },
            "left": 0,
            "top": 0,
            "right": 0,
            "bottom": 0,
            "transform": {
              "xx": 1.3601764888729304,
              "xy": 0,
              "yx": 0,
              "yy": 1.3627518109295933,
              "tx": 203.50000000000003,
              "ty": 20.704124478480498
            }
          },
          "image": {}
        }
      ]
    }
  ],
  "document": {
    "width": 320,
    "height": 50,
    "resources": {
      "layerComps": [],
      "guides": [],
      "slices": []
    }
  }
}

2 个答案:

答案 0 :(得分:7)

你在第二级有拼错'儿童'。

   <div ng-repeat="child in jdata.children">
        <div ng-repeat="childsub in child.childrens">
            <div ng-repeat="text in childsub.text">
              <span>{{text.name}}</span>
            </div>
        </div>
    </div>

答案 1 :(得分:0)

在第二个div子项中没有名为&#34; children&#34; 的属性。您有一个名为&#34; 儿童&#34;的属性。只需在第二个div中使用儿童而不是儿童,它应该可以使用。