私はこのコードを持っています:
var app = angular.module('app', []);
app.controller('RadioCtrl', ['$scope', '$http',
function($scope, $http) {
$http.jsonp('http://www.filltext.com/?callback=JSON_CALLBACK&rows=5&fname={firstName}&lname={lastName}&id={index}').success(function(data) {
$scope.people = data;
})
}
]);
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<title>Radio button</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
</head>
<body>
<section ng-controller="RadioCtrl">
<input type="text" ng-model="pepek.fname">
<br>Ascended
<input type="radio" ng-model="direction" checked>Descended
<input type="radio" ng-model="direction" value="reverse">
<table>
<thead>
<tr>
<th>ID</th>
<th>First Name</th>
<th>Second name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="person in people| filter:pepek |orderBy:person.id">
<td>{{person.id}}</td>
<td>{{person.fname}}</td>
<td>{{person.lname}}</td>
</tr>
</tbody>
</table>
</section>
</body>
</html>
[昇順] または [降順] のラジオ ボタンをクリックすると、テーブルが ID 順に並べられます。orderBy:id
シンプルまたはorderBy:-id
またはorderBy:person.id
またはorderBy:id:reverse
またはそれらのケースのいずれかを試してもorderBy:id:direction
、IDで昇順が並んでいなかった場合でも、常に降順になり、理由がわかりません。前もって感謝します :)