[英]Angular Material design date format
I'm working with angular material design. 我正在处理角材料设计。 ( https://material.angularjs.org/#/ ) I have the following piece of code:
( https://material.angularjs.org/#/ )我有以下代码:
<md-input-container padding>
<label>Some date</label>
<input ng-model="searchQuery.SomeDate" type="date" name="invoiceDate" />
</md-input-container>
This gives me a very nice text-box with a datepicker. 这给了我一个带有日期选择器的非常漂亮的文本框。 The user is able to type the date manually or pick a date from the datepicker.
用户可以手动键入日期或从日期选择器中选择一个日期。 Problem is that based on the ui culture the user must type in either dd-MM-yyyy format or MM-dd-yyyy format.
问题是,基于ui文化,用户必须以dd-MM-yyyy格式或MM-dd-yyyy格式键入。
I do not want this. 我不想这样。 I want to force the dd-MM-yyyy format.
我想强制使用dd-MM-yyyy格式。 But I don't know how to.
但是我不知道该怎么办。 Do you?
你呢?
Thanks in advance! 提前致谢!
If you include a script from i18n, you can directly set your date param to your country's convention. 如果包含i18n中的脚本,则可以直接将日期参数设置为您所在国家/地区的约定。
This is the list of files : https://code.angularjs.org/1.0.8/i18n/ 这是文件列表: https : //code.angularjs.org/1.0.8/i18n/
Then a simple include will work : 然后一个简单的include将起作用:
<script src="http://code.angularjs.org/1.0.8/i18n/angular-locale_XXXX.js"></script>
You want something like this: 您想要这样的东西:
User sees dd/MM/yyyy, but in program it is a date? 用户看到dd / MM / yyyy,但是在程序中是日期? I use it like this:
我这样使用它:
<span class="input-group">
<input type="text" datepicker-popup="dd/MM/yyyy" is-open="opened" close-text="Close"/>
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open($event)">
<i class="glyphicon glyphicon-calendar"></i></button>
</span>
</span>
and data sent into model is formated after dd/MM/yyyy 并且发送到模型中的数据的格式为dd / MM / yyyy
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.