Heim  >  Fragen und Antworten  >  Hauptteil

ng-repeat 2-Level-Schleife – Stapelüberlauf

<li ng-repeat="a in b">
<a>{{a.id}}</a> //这里是循环数组出id
<ul>
    <li ng-repeat="">{{}}</li> //这里该怎么循环出arr的name?
</ul>
</li>

Datenstruktur

[
{"id":1,
  "ps":1,
  "arr":[{"name":2,"user":13},{"name":3,"user":24}]
},
{"id":2,
 "ps":2,
 "arr":[{"name":4,"user":34},{"name":5,"user":45}]
}
]
PHP中文网PHP中文网2734 Tage vor582

Antworte allen(3)Ich werde antworten

  • 给我你的怀抱

    给我你的怀抱2017-05-16 13:20:45

    <li ng-repeat="a in b">
    {{a.id}} //这里是循环数组出id
    <ul>

    <li ng-repeat="c in a.arr">{{c.name}}</li> //这里该怎么循环出arr的name?

    </ul>
    </li>

    这样子不可以吗?

    Antwort
    0
  • 迷茫

    迷茫2017-05-16 13:20:45

    <li ng-repeat="a in b">
        <a>{{a.id}}</a> 
        <ul>
            <li ng-repeat="c in a.arr">{{c.name}}</li>
        </ul>
    </li>

    Antwort
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-16 13:20:45

    $scope.b=[
            {"id":1,
                "ps":1,
                "arr":[{"name":2,"user":13},{"name":3,"user":24}]
            },
            {"id":2,
                "ps":2,
                "arr":[{"name":4,"user":34},{"name":5,"user":45}]
            }
        ]
    <li ng-repeat="a in b">
        <a>{{a.id}}</a>
        <ul>
            <li ng-repeat="c in a.arr">{{c.name}}</li>
        </ul>
    </li>

    Antwort
    0
  • StornierenAntwort