我有这个代码:
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
or orderBy:-id
or orderBy:person.id
or or orderBy:id:reverse
or orderBy:id:direction
not 这些案例没有按 ID 排列升序,它总是降序,我不知道为什么。先感谢您 :)