Use filter on ng-options label - NOT WORKING

£可爱£侵袭症+ 提交于 2019-12-13 18:59:33

问题


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

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

I am trying this;

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

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

Thanks.


回答1:


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

2015-11-05 06:00:00 should be changed to 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'},
];

Demo Here



来源:https://stackoverflow.com/questions/33551653/use-filter-on-ng-options-label-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!