角度顺序按日期 [英] Angular orderBy Date
本文介绍了角度顺序按日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数组,我想在 Angular.js 中按日期排序:
I have an array which I want to order by date in Angular.js:
<tr ng-repeat="er in vm.readerFeeds | orderBy:'-publishedDate'">
<td>{{er.publishedDate}}</td>
</tr>
列表排序不正确.我认为日期格式是原因?
The list ist not ordered right. I think the date format is the cause?
日期格式为:
Sat, 09 Nov 2013 04:26:55 -0800
推荐答案
为了使 orderBy
工作,你需要用 new Date(/**/)<的对象包装字符串日期/code> 在控制器中.
To make to orderBy
to work you need wrap string date with object of new Date(/**/)
in controller.
例如:
$scope.vm.readerFeeds = [
{
//.....
publishedDate: new Date(/*your string date*/);
},
{
//.....
publishedDate: new Date(/*your string date*/);
}
];
这篇关于角度顺序按日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文