在角度js中,第一个值应为emty
<thead>
<tr ng-repeat="(key, value) in reports">
<th> </th>
<th ng-if="$parent.$index==0" ng-repeat="data in value">{{$index+1}}</th>
</tr>
</thead>
如何将第一个值从第二个<th>
答案 0 :(得分:0)
使用$first
检查当前项目是否是集合中的第一项:
angular.module('app', [])
.controller('ctrl', function($scope) {
$scope.reports = {
first: 1,
second: 2
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
<table>
<thead>
<tr ng-repeat="(key, value) in reports">
<th ng-if="$first"> </th>
<th ng-if="!$first">{{key}}</th>
</tr>
</thead>
</table>
</div>