我收到的回复数据为:
array=[{"job id":"1",
"level 1":"er",
"level 2":"ED",
"level 3":"MT",
"status":"mt"
},
{"job id":"2",
"level 1":"ear",
"level 2":"ED",
"level 3":"MT",
"status":"mt"}
]
在上面的数组中,有两个从数据库中检索的记录,它可能会有相应的变化。
我希望以表格格式表示,列必须是作业ID,级别1,级别2等,以及值1,ed等,如在角度JS中。
答案 0 :(得分:0)
尝试在(key,value)
ng-repeat
var app=angular.module('app',[])
app.controller("Ctrl",function($scope,$filter){
$scope.array=[
{"job id":"1","level 1":"er","level 2":"ED","level 3":"MT","status":"mt"},
{"job id":"2","level 1":"ear","level 2":"ED","level 3":"MT","status":"mt"}
]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller=" Ctrl">
<table border="1">
<thead>
<tr ng-repeat="(key,value) in array" ng-if="$last">
<td ng-repeat="(key,v) in value">{{key}}</td>
</tr>
</thead>
<tr ng-repeat="(key,value) in array">
<td ng-repeat="(key,v) in value">{{v}}</td>
</tr>
</table>
</div>