Angularjs mdDatepicker时区问题
我有一个mdDatepicker输入,它返回一个错误,说“错误:md datepicker的ng模型必须是一个日期实例。当前模型是一个字符串”。经过一些挖掘,我在github上找到了这篇文章:并替换了ngMaterial指令中的这段代码:Angularjs mdDatepicker时区问题,angularjs,datepicker,angularjs-material,Angularjs,Datepicker,Angularjs Material,我有一个mdDatepicker输入,它返回一个错误,说“错误:md datepicker的ng模型必须是一个日期实例。当前模型是一个字符串”。经过一些挖掘,我在github上找到了这篇文章:并替换了ngMaterial指令中的这段代码: if (value && !(value instanceof Date)) { throw Error('The ng-model for md-datepicker must be a Date instance. ' +
if (value && !(value instanceof Date)) {
throw Error('The ng-model for md-datepicker must be a Date instance. ' +
'Currently the model is a: ' + (typeof value));
}
为此:
if (value && !(value instanceof Date)) {
var parseValue = self.dateLocale.parseDate(value);
if (isNaN(parseValue)) {
throw Error('The ng-model for md-datepicker must be a Date instance. ' +
'Currently the model is a: ' + (typeof value));
} else {
value = parseValue;
}
}
这解决了ng模型字符串的问题,但现在我面临另一个问题,那就是时区。例如,当我现在单击mdDatepicker并选择2017年11月30日时,在按下save并刷新页面后,mdDatepicker始终显示前一天。在这种情况下,将显示2017年11月29日为所选日期
我可以在上面的代码片段中添加一些东西来解决这个问题吗?任何建议都将不胜感激