NG选项标签上使用过滤器 - 不工作 [英] Use filter on ng-options label - NOT WORKING

查看:214
本文介绍了NG选项标签上使用过滤器 - 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图格式化从我使用内NG选项时集合的时间值。

I am trying to format a time value from a collection I am using for time within ng-options.

在DB的格式为00:00:00,但我想present 00:00 AM / PM给用户。

The format in the db is 00:00:00 but I want to present 00:00 AM/PM to the user.

我想这一点;

NG选项=选定了time.time为(选定了time.time |日期:'H:MMA),在次时代

ng-options="time.time as (time.time | date:'h:mma') for time in times"

由于没有运气。好像应该pretty直线前进。 shortTime也不行。

With no luck. Seems like it should be pretty straight forward. shortTime does not work either.

感谢。

推荐答案

基本上你的日期应该以正确的格式返回,这样它会被识别为日期日期过滤

Basically your date should return in correct format so that it would be recognized as date by the date filter

2015年11月5日06:00:00 应改为 2015-11-05T06:00:00

$scope.times = [
    {time: '2015-11-05T01:00:00', id: '1'},
    {time: '2015-11-05T02:00:00', id: '2'},
    {time: '2015-11-05T03:00:00', id: '3'},
    {time: '2015-11-05T13:00:00', id: '4'},
];

演示这里

这篇关于NG选项标签上使用过滤器 - 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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