Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs mdDatepicker时区问题_Angularjs_Datepicker_Angularjs Material - Fatal编程技术网

Angularjs mdDatepicker时区问题

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. ' +

我有一个mdDatepicker输入,它返回一个错误,说“错误:md datepicker的ng模型必须是一个日期实例。当前模型是一个字符串”。经过一些挖掘,我在github上找到了这篇文章:并替换了ngMaterial指令中的这段代码:

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日为所选日期

我可以在上面的代码片段中添加一些东西来解决这个问题吗?任何建议都将不胜感激