Html AngularJS向上/向下排序图标不是';看不见
我尝试在表标题的单击事件上对表数据进行排序。但无法相应地看到向上/向下图标。 我的代码的代码笔是 请告诉我哪里做错了 这是我的密码 安格拉斯Html AngularJS向上/向下排序图标不是';看不见,html,angularjs,twitter-bootstrap,Html,Angularjs,Twitter Bootstrap,我尝试在表标题的单击事件上对表数据进行排序。但无法相应地看到向上/向下图标。 我的代码的代码笔是 请告诉我哪里做错了 这是我的密码 安格拉斯 var myApp = angular.module("myModule", []); myApp.controller("sortctrl", function ($scope) { var students = [{ "name": "Shirl MacCallister", "class": 7, "section": "B"
var myApp = angular.module("myModule", []);
myApp.controller("sortctrl", function ($scope) {
var students = [{
"name": "Shirl MacCallister",
"class": 7,
"section": "B",
"rollno": 203,
"gender": "Female"
}, {
"name": "Florance Skilbeck",
"class": 6,
"section": "A",
"rollno": 240,
"gender": "Female"
}];
it'll work
$scope.students = students;
$scope.sortcolumn = "rollno";
$scope.reversesort = false;
$scope.sortdata = function (column) {
$scope.reversesort = ($scope.sortcolumn == column) ? !$scope.reversesort : false;
$scope.sortcolumn = column;
}
$scope.getsortclass = function (column) {
if ($scope.sortcolumn == column) {
return $scope.reversesort ? '.arrow-down' : '.arrow-up'
}
return '';
} });
HTML
名称
卷号。
等级
部分
{{student.name}
{{student.rollno}
{{student.class}
{{student.section}
请不要将此问题标记为重复问题,我还没有找到解决S/O问题的方法这里有一个有效版本: 您需要删除
调用(getsortclass
,而不是getsortclass('')
)getsortclass('')
中类名前的点(getsortclass
,而不是'arrow-down'
)'。arrow-down'
<body ng-app="myModule">
<div class="container" ng-controller="sortctrl">
<br><br>
<table class="table">
<thead>
<tr role="button" style="cursor: pointer">
<th ng-click="sortdata('name')">Name<div ng-class="getsortclass('name')"></div></th>
<th ng-click="sortdata('rollno')">Roll No.<div ng-class="getsortclass.('rollno')"></div></th>
<th ng-click="sortdata('class')">Class<div ng-class="getsortclass.('class')"></div></th>
<th ng-click="sortdata('section')">Section<div ng-class="getsortclass.('section')"></div></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="student in students | orderBy:sortcolumn:reversesort" >
<td>{{ student.name }}</td>
<td>{{ student.rollno }}</td>
<td>{{ student.class }}</td>
<td>{{ student.section }}</td>
</tr>
</tbody>
</table>
</div>
</body>