目前如果我篩選,$ index也會更新。所以如果有500個結果,我篩選排名,也會更新。我如何擁有一個不更新的索引列?
這裏是我的代碼:
<input ng-model="query.teamName" /></div>
<table class="table">
<thead>
<tr>
<th>Rank</th>
<th>Team</th>
<th>Location</th>
<th>Score</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="team in teams | filter:query | orderBy:orderByScore:reverseSort">
<td><span style="color:white">{{$index+1}}</span></td>
<td>{{team.teamName}}</td>
<td>{{team.teamLocation}}</td>
<td>{{team.teamPoints | number:2}}</td>
</tr>
</tbody>
</table>
控制器:
scoreboard.controller('scoreboardCtrl', function ($scope, $filter) {
$scope.orderByScore = 'teamPoints';
$scope.reverseSort = true;
$scope.teams = [
{ "teamName": "motorboat skydive", "teamLocation": "1189 King", "teamPoints": 35.53},
{ "teamName": "the grinders", "teamLocation": "1189 King", "teamPoints": 127.90},
{ "teamName": "team forrec", "teamLocation": "1189 King", "teamPoints": 29.46},
{ "teamName": "bikini finger", "teamLocation": "1189 King", "teamPoints": 21.98},
{ "teamName": "la familia", "teamLocation": "1189 King", "teamPoints": 148.32},
{ "teamName": "darkness is", "teamLocation": "1189 King", "teamPoints": 108.88},
{ "teamName": "grinders", "teamLocation": "1189 King", "teamPoints": 167.95},
{ "teamName": "discarded youth", "teamLocation": "1189 King", "teamPoints": 55.52}
];
};
你可以發佈信息ü控制器嗎? – DeadCalimero 2014-09-23 18:50:53
控制器添加了 – milkman15 2014-09-23 18:55:31