I have a list sorted by date and I want to reorder it by clicking button. This date is taken from an object, I try this code, but it sorts like a simple number:
我有一个按日期排序的列表,我想通过单击按钮重新排序。这个日期来自一个对象,我尝试这个代码,但它的排序就像一个简单的数字:
// function to order and change button by click
$scope.sortType = "CreationDate";
$scope.sortReverse = false;
$scope.buttonStyle = "icon ion-ios-time-outline";
$scope.buttonPress = false;
$scope.ordina = function() {
if ($scope.sortType == "CreationDate") {
$scope.sortReverse = !$scope.sortReverse;
console.log("riordinate");
}
$scope.buttonPress = !$scope.buttonPress;
if ($scope.buttonPress == true) {
$scope.buttonStyle = "icon ion-ios-time";
} else {
$scope.buttonStyle = "icon ion-ios-time-outline";
}
}
in html:
<ion-item ng-repeat="object in allODA | filter: searchQuery | orderBy : sortType : sortReverse " href="#/app/ODA_Detail/{{object.caseTaskId}}">
any solutions???idea???
1 个解决方案
#1
0
I don't know if I understood correctly, but here is an example to sort a table with dates, click on the title of the column to sort it.
我不知道我是否理解正确,但这里是一个用日期对表进行排序的示例,单击列的标题对其进行排序。
https://jsfiddle.net/lisapfisterer/8pvqau4z/
This does not use ionic, you might need to adapt it.
这不使用离子,你可能需要适应它。
<table class="table table-striped">
<thead>
<td data-ng-click="sortType = name; sortReverse = !sortReverse;">
Date
</td>
<td data-ng-click="sortType = name; sortReverse = !sortReverse;">
Name
</td>
</thead>
<tbody>
<tr ng-repeat="item in allItems | orderBy:sortType:sortReverse">
<td>{{item.date | date:"yyyy-MM-dd"}}</td>
<td>{{item.name}}</td>
</tr>
</tbody>
</table>
#1
0
I don't know if I understood correctly, but here is an example to sort a table with dates, click on the title of the column to sort it.
我不知道我是否理解正确,但这里是一个用日期对表进行排序的示例,单击列的标题对其进行排序。
https://jsfiddle.net/lisapfisterer/8pvqau4z/
This does not use ionic, you might need to adapt it.
这不使用离子,你可能需要适应它。
<table class="table table-striped">
<thead>
<td data-ng-click="sortType = name; sortReverse = !sortReverse;">
Date
</td>
<td data-ng-click="sortType = name; sortReverse = !sortReverse;">
Name
</td>
</thead>
<tbody>
<tr ng-repeat="item in allItems | orderBy:sortType:sortReverse">
<td>{{item.date | date:"yyyy-MM-dd"}}</td>
<td>{{item.name}}</td>
</tr>
</tbody>
</table>