AngularJS ngRepeat orderBy不能与DateTime字符串一起使用 [英] AngularJS ngRepeat orderBy not working with DateTime string

查看:63
本文介绍了AngularJS ngRepeat orderBy不能与DateTime字符串一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅此JSFiddle http://jsfiddle.net/luke88jones/MfLqa/2/

Please see this 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字符串放入并尝试使用此字符串进行排序,但它似乎仍然无法正常工作.

I am trying to use the orderBy to sort a ng-repeat. Our data currently uses the bookingDateTime for the filter which isn't working. I wasn't sure if angular wasn't resolving the function so have put in the sortDate property as an ISO string and tried to sort using this but still it doesn't seem to be working.

有什么想法吗?

推荐答案

尝试以下方法:

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

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

这篇关于AngularJS ngRepeat orderBy不能与DateTime字符串一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆