[英]Unable to sort date column in table
I have two columns in a table. 我在表中有两列。 I can sort the location column asc/desc just fine.
我可以对位置列asc / desc进行排序。 However, I cannot do the same thing with the date column.
但是,我不能对date列执行相同的操作。 It seems I can sort it once, but whenever I try to sort it again, it does nothing.
似乎我可以对其进行一次排序,但是每当我尝试再次对其进行排序时,它什么都不做。
Please see the fiddle http://jsfiddle.net/poppypoop/2463hsvd/ 请参阅小提琴http://jsfiddle.net/poppypoop/2463hsvd/
If you click the 'Date' header, it sorts. 如果您单击“日期”标题,它将进行排序。 However, clicking it again does nothing.
但是,再次单击它无济于事。 This is not the case with the Location column.
“位置”列不是这种情况。 What am I doing wrong?
我究竟做错了什么?
controller 调节器
function myCtrl($scope){
$scope.descending = false;
$scope.columnToOrderBy = 'date';
$scope.data = [
{
date: "2014-06-19T05:00:00",
Location: "California"
},
{
date: "2014-07-13T08:00:00",
Location: "Texas"
},
{
date: "2013-07-13T08:00:00",
Location: "Florida"
}
];
}
html HTML
<table cellspacing="0" cellpadding="5" border="2">
<tr>
<th ng-click=" columnToOrderBy ='Date'; descending = !descending">
Date
</th>
<th ng-click=" columnToOrderBy ='Location'; descending = !descending">
Location
</th>
</tr>
<tr ng-repeat="item in data | orderBy:columnToOrderBy:descending">
<td>{{item.date | date:"MM/dd/yyyy h:mma"}}</td>
<td>{{item.Location}}</td>
</tr>
</table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.