AngularJS ngRepeat orderBy不使用DateTime字符串

时间:2014-03-19 11:07:44

标签: javascript angularjs

请参阅此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作为过滤器,该过滤器不起作用。我不确定如果角度没有解析函数,所以将sortDate属性作为ISO字符串放入并尝试使用它进行排序,但它似乎并没有起作用。

有什么想法吗?

1 个答案:

答案 0 :(得分:6)

请改为尝试:

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

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