角UI一天从日期UI的日期减去 [英] Angular-UI One day is subtracted from date in ui-date

查看:142
本文介绍了角UI一天从日期UI的日期减去的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况
我想使用的用户界面的最新设置/编辑我的应用程序的日期。我用角,角的UI和jQuery的UI等方面的最新的稳定版本。

The situation I want to use ui-date to set/edit a date in my app. I use the latest stable versions of angular, angular-ui, jquery-ui etc.

问题
作为一个日期是使用日期选择器选择很快就在我的模型的日期将等于选定的日期减去1天。它也将获得发送到我的服务器,并保存在我的数据库这个样子。

The problem As soon as a date is selected using the datepicker the date in my model will equal the selected date minus 1 day. It will also get send to my server and saved in my database this way.

的plunker
http://plnkr.co/edit/Ft14Wa?p=$p$pview
最初在日期选择器输入的日期和在我的模型的时间是相同的。采摘它们不同的日期之后。

The plunker http://plnkr.co/edit/Ft14Wa?p=preview Initially the date in the datepicker input and the date in my model are the same. After picking a date they differ.

问题
这是怎么回事(WR)对(G),这里???

The question What is going (wr)on(g) here???

推荐答案

用户界面的最新预计,模型是一个实际的日期对象。你的情况,这是一个字符串。如果你看看在控制台上,你会看到,实际上angularUI通知您有关。然后,它会建议您添加额外的UI的日期格式标记与它的日期字符串会被解析成日期对象指定的日期格式。

ui-date expects your model to be an actual date object. In your case it's a string. If you take a look at the console you'll see that angularUI actually informs you about that. Then it advises you to add additional ui-date-format tag with the specified date format with which your date string will be parsed into date object.

长话短说,您需要调整您的输入作为这样的:

Long story short, your need to adjust your input as this:

<input ui-date="{dateFormat: 'yy-mm-dd'}" ui-date-format="yy-mm-dd" ng-model="customer.contract_end_date"></input>

工作plunker

这篇关于角UI一天从日期UI的日期减去的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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