我需要在AngularJS app中显示一些数据。
我从API获取JSON并显示“父”值。我使用ng-repat执行此操作,这是可以的,但是当用户从ng-repeat中单击此值时,我需要显示可折叠数据,但我无法从我的JSON访问第二级。
<div class="logBox" style="overflow-y: auto; height: 250px;">
<div class="list" ng-repeat="(key, value) in lists">
<a ng-click="collapseIt($index)">{{key}}</a>
<div class="list" ng-repeat="list in value track by list.id">
<div ng-if="collapseId==$index">
<span>
<img class="logImg" ng-if="list.priority == 0" src="" alt="success" />
<img class="logImg" ng-if="list.priority == 1" src="" alt="warning" />
<img class="logImg" ng-if="list.priority == 2" src="" alt="error" />
</span>
<span>
<strong>{{list.update_dt}}</strong>
</span>
<span>{{list.type}}</span>
<span>{{list.serial_number}}</span>
</div>
</div>
</div>
和js
$scope.collapseIt = function(id) {
$scope.collapseId = ($scope.collapseId == id) ? -1 : id;
}
以下是我尝试过的内容:fiddle
如何访问此文件?