我已经使用angular完成了一个基本的表排序应用程序,排序正在进行但问题是我没有得到以ASCII值排序的值
任何人都可以告诉我该怎么做
HTML
<div ng-app ng-controller="ArrayController">
<table>
<th ng-repeat="header in headers">
<a ng-click="sort_by(header)">{{ headers[$index] }}</a>
</th>
<tr ng-repeat="arr in records |orderBy:sortingOrder:reverse">
<td ng-repeat="val in arr" ng-bind-html-unsafe="arr[headers[$index]]"></td>
</tr>
</table>
</div>
脚本
function ArrayController($scope) {
$scope.headers = ['col1', 'col2'];
$scope.records = [{col1: 'a1', col2: 'd1'}, {col1: 'c2', col2: 'A2'}, {col1: 'b3', col2: 'c3'}, {col1: 'd4', col2: 'a1'}];
$scope.reverse = true;
$scope.sort_by = function(newSortingOrder)
{
if ($scope.sortingOrder === newSortingOrder)
{
$scope.reverse = !$scope.reverse;
}
$scope.sortingOrder = newSortingOrder;
};
}