AngularJs orderBy作为字符串处理日期

时间:2015-02-20 11:07:20

标签: angularjs date filter sql-order-by firebase

AngularJs orderBy将日期视为字符串。我希望在日期获得订单作为数字值,因为它比较了第一个日期,然后是月份和年份。我的json数据如下:

"simplelogin:23" : {
          "chatdiscussion" : "He",
          "nextstep" : "The",
          "sessiondate" : "7 January 2015 +0530",
          "studentemail" : "damchoe.pem1234@gmail.com",
          "studentname" : "Damchoe"
          },

现在我希望带有最新日期的数据首先出现,但它首先过滤日期,然后将月份作为字符串逐年过滤 请帮我摆脱这个。

1 个答案:

答案 0 :(得分:3)

您无法对字符串进行过滤,例如" 2015年1月7日+ 0530" ...

你必须要么:

  • 在您的JSON Feed中返回更标准/可过滤的日期格式,例如" YYYY-MM-DD HH:ii:ss"
  • 将您的JSON日期转换为可过滤的内容(您可以尝试使用moment.js
相关问题