javascript AngularJS ui-date 格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13328756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
AngularJS ui-date format
提问by Tom
So I have :
所以我有 :
<input ng-model="date1" ui-date>
<div ng-model="date2" ui-date></div>
It works great. The div calendar 'date2' will follow the change of its previous ui-date input, namely 'date1' the input box.
它工作得很好。div 日历 'date2' 将跟随它之前的 ui-date 输入的变化,即 'date1' 输入框。
AngularUI did a great job, when you have multiple input+div calendars existing in one page, imagine a travel agent booking page, 'date4' will group with 'date3' automatically, 'date6' will group with 'date5' automatically ...etc. well done.
AngularUI 做得很好,当你在一个页面中存在多个 input+div 日历时,想象一个旅行社预订页面,'date4' 将自动与 'date3' 分组,'date6' 将自动与 'date5' 分组......等等。做得好。
However, in my sample code <input ng-model="date1" ui-date>
only works in US format with back-slash delimiters 'MM/dd/yyyy'.
但是,在我的示例代码中,<input ng-model="date1" ui-date>
仅适用于带有反斜杠分隔符“MM/dd/yyyy”的美国格式。
My question is, how do I change the default input date format? If I want to have iso-8601 'yyyy-MM-dd' as my input, ui-date doesn't seem to recognise it as a valid input.
我的问题是,如何更改默认输入日期格式?如果我想将 iso-8601 'yyyy-MM-dd' 作为我的输入,则 ui-date 似乎无法将其识别为有效输入。
I tried ui-date="yyyy-MM-dd"
it doesn't seem to have any effects.
我试过ui-date="yyyy-MM-dd"
好像没什么效果。
回答by maxisam
Since this is a wrapper for the datepicker in jQueryUI, you should check the document here
由于这是 jQueryUI 中日期选择器的包装器,因此您应该在此处查看文档
You can set it like this
你可以这样设置
ui-date="{ dateFormat: 'yy-mm-dd' }"
Here is the plunker
这里是plunker