Javascript 如何将JSON对象映射到ng repeat中的折叠行
我有一个来自数据库的JSON对象作为一个大对象,例如:Javascript 如何将JSON对象映射到ng repeat中的折叠行,javascript,json,angularjs,ng-repeat,Javascript,Json,Angularjs,Ng Repeat,我有一个来自数据库的JSON对象作为一个大对象,例如: $scope.totalsum = { "A1": 1155000, "A2": null, "A3": 2133, "A31": 29292, "A32": 2321, "A33": 232342, etc.... }, 我需要A31和A32等来填充折叠的表数
$scope.totalsum =
{
"A1": 1155000,
"A2": null,
"A3": 2133,
"A31": 29292,
"A32": 2321,
"A33": 232342,
etc....
},
我需要A31和A32等来填充折叠的表数据行。以下是到目前为止对象的ng重复:
<tr ng-repeat-start="data in totalsum" ng-click="isRowCollapsed=!isRowCollapsed">
<td>
<input class="form-control" placeholder="{{data.total | number:2}}">
</td>
</tr>
<tr ng-repeat-end ng-show="data.breakdown.length>0" ng-hide="isRowCollapsed">
<td ng-show="data.breakdown.length>0">
<div class="subvalues" ng-repeat="subvalues in data.breakdown">
<input class="form-control" placeholder="{{subvalues.subtotal | number:2}}">
</div>
</td>
</tr>
<tr>
<td>
<input class="form-control" placeholder="{{getTotal('total') | number:2}}">
</td>
</tr>
据我所知,您可以使用ng repeat with(key,value)选项来解决此问题:
<tr ng-repeat="(key, value) in totalsum">
<td> {{key}} </td> <td> {{ value }} </td>
</tr>
{{key}}{{value}}
问题在于来自数据库的对象只是一个一级JSON脚本。我需要将A12 A13 A14、A21 A22 A23等任何内容映射到折叠的表数据行
<tr ng-repeat="(key, value) in totalsum">
<td> {{key}} </td> <td> {{ value }} </td>
</tr>