2
我想顯示和隱藏按照排序箭頭圖標。我在角的js是新請幫助 我使用自舉顯示和隱藏箭頭圖標按角度.js排序
<div ng-controller="PurchasesCtrl">
<h2>Purchases:</h2>
<table class="table">
<thead>
<tr >
<th ng-click="changeSorting('username')" >UserName <span class="glyphicon glyphicon-chevron-up"></span><span class="glyphicon glyphicon-chevron-down"></span></th>
<th ng-click="changeSorting('usertype')">UserType</th>
<th ng-click="changeSorting('age')" >Age</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="purchase in purchases.data|orderBy:sort.column:sort.descending">
<td >{{purchase.username}}</td>
<td>{{purchase.usertype}}</td>
<td>{{purchase.age}}</td>
</tr>
</tbody>
</table>
</div>
角JS排序
VAR對myApp = angular.module( 「對myApp」,[]) ;
myApp.factory("Purchases", function(){
var Purchases = {};
Purchases.data = [
{
username: "suraj kumar gosi",
usertype: "sponer",
age: "20"
},
{
username: "kao kumar gosi",
usertype: "clinet",
age: "26"
},
{
username: "surdfsdfaj kumar gosi",
usertype: "clinfsdfset",
age: "50"
}
];
return Purchases;
});
function PurchasesCtrl($scope, Purchases){
$scope.purchases = Purchases;
$scope.sort = {
column: '',
descending: false
};
$scope.changeSorting = function(column) {
var sort = $scope.sort;
if (sort.column == column) {
sort.descending = !sort.descending;
} else {
sort.column = column;
sort.descending = false;
}
};
}
請高興這一點。在此先感謝
謝謝你,但是我加入
對不起,我不確定是什麼你的意思是......你可以用你的問題做一個jsFiddle或者codepen嗎? – azium
http://jsfiddle.net/js64b/873/ 當我點擊一個提交然後移動所有箭頭圖標。但我想在一次移動只有一個圖標 請提前幫助在此謝謝 – Surajghosi
入住此plunker:plunker to show icons on sorting
,而不是更改的圖標,額外的功能,我們可以使用CSS和功能排序:`$ scope.reverse = false; $ scope.sortKey ='title';
和HTML如下:
來源
2017-01-07 11:50:29
相關問題