【问题标题】:AngularJS ngRepeat orderBy not working with DateTime stringAngularJS ngRepeat orderBy 不使用 DateTime 字符串
【发布时间】:2014-03-19 11:07:44
【问题描述】:

请看这个 JSFiddle http://jsfiddle.net/luke88jones/MfLqa/2/

<div ng-repeat="booking in testBookings | orderBy: 'booking.sortDate'">
      <span>{{booking.bookingDateTime | date:'dd-MMM-yy HH:mm'}}</span>      
</div>

我正在尝试使用 orderBy 对 ng-repeat 进行排序。我们的数据当前使用 bookingDateTime 作为过滤器,但它不起作用。我不确定 angular 是否没有解析该函数​​,因此已将 sortDate 属性作为 ISO 字符串放入并尝试使用它进行排序,但它似乎仍然无法正常工作。

有什么想法吗?

【问题讨论】:

    标签: javascript angularjs


    【解决方案1】:

    试试这个:

    <div ng-repeat="booking in testBookings | orderBy:'sortDate'">
    

    工作小提琴:http://jsfiddle.net/Bq7hb/

    【讨论】:

    • 如果日期来自不同时区,则无法正确排序
    猜你喜欢
    • 2017-05-13
    • 1970-01-01
    • 1970-01-01
    • 2014-06-01
    • 2016-08-25
    • 2015-04-22
    • 2015-03-13
    • 2015-12-05
    • 1970-01-01
    相关资源
    最近更新 更多