angularjs - angularjs daterangepicker 日历显示不正确的日期
问题描述
我在我的 angularjs 应用程序中使用了angularjs-daterangepicker。从下图中可以看出,日期显示错误。
<button type="button"
ng-click="$ctrl.DateRangeChanged()"
date-range-picker="$ctrl.durationDateRange"
ng-model="$ctrl.date"
options="$ctrl.options" >Customize
</button>
日期范围选项如下
this.options = {
pickerClasses: 'custom-display', // angular-daterangepicker extra
buttonClasses: 'btn',
applyButtonClasses: 'btn-primary',
cancelButtonClasses: 'btn-danger',
locale: {
applyLabel: 'Apply',
cancelLabel: 'Cancel',
customRangeLabel: 'Custom range',
separator: ' - ',
format: 'YYYY-MM-DD', // will give you 2017-01-06
// format: "D-MMM-YY", // will give you 6-Jan-17
// format: "D-MMMM-YY", //will give you 6-January-17
},
timePicker: true,
autoApply: true,
showDropdowns: true,
startDate: (moment()).startOf('day'),
};
解决方案
您必须在输入中添加日期范围选择器选项
<button type="button"
ng-click="$ctrl.DateRangeChanged()"
date-range-picker="$ctrl.durationDateRange"
ng-model="$ctrl.date"
date-range-picker-options="$ctrl.options" >Customize
</button>
推荐阅读
- c# - Silverlight - 工具包中的 ComboBox 和其他字段:DataForm 在 .xaml.cs 中不可用
- performance - 有没有更快的方法通过 PowerShell 脚本移动图片
- javascript - Vis.js 时间轴动态变化
- sql - 从 text(char(50)) 转换为日期时间
- c# - 防止丢失智能卡的 Windows 安全弹出窗口
- ms-access - 命令按钮的单击事件不会针对相同形式的不同记录更新
- postgresql - Postgres 表空间检测是 linux 还是 windows
- docker - 为什么在 docker 上运行 go api 在被邮递员击中时会给出响应?
- github - 如何将文件夹 / GitHub 存储库链接到 Heroku?
- mysql - 在 mysql sp 中处理单引号和双引号