我試圖格式化'分數'系統。我什麼回報JSON是「標題」和「分數」 - 我非常希望它的格式是這樣的:AngularJS:重複並按數字範圍過濾
100 --------
標題 - 99
標題 - 91
90 --------
標題 - 89
標題 - 81
80 --------(等等)
我已經做到了,所以我的分數是從最高到最低的順序,但我不知道如何過濾範圍和以某種方式偷偷摸摸用於主「100,90,80」計數/標題區的額外表格行。
HTML代碼:
<body ng-app="myApp" ng-controller="myCtrl">
<table class="table">
<tbody>
<tr ng-repeat="x in myData | orderBy:'title' | orderBy:'-score'">
<td>{{x.title}}</td>
<td>{{x.score}}</td>
</tr>
</tbody>
</table>
</body>
AngularJS:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get("scores.json").then(function (response) {
$scope.myData = response.data;
});
});
我想也許一個for循環或if語句會的工作,但我不知道如何它放到angularjs的選項/過濾器等
在你的ngrepeat中,你可以有一個ngif來檢查$ index是否可以被10整除 – ksav