我得到这个错误The ng-model for md-datepicker must be a Date instance. Currently the model is a: string
。我在模型md- datePicker - 日期实例错误总是
Contact.prototype.getSetIncorporated = function(date) {
if (arguments.length) {
this.company.information.incorporatedObject = date;
this.company.information.incorporated = moment.utc(date).format('X');
}
if (!this.company.information.incorporatedObject) {
if (this.company.information.incorporated !== '') {
this.company.information.incorporatedObject = moment.utc(this.company.information.incorporated, 'X').toDate();
} else {
this.company.information.incorporatedObject = null;
}}
return this.company.information.incorporatedObject;
}
我也尝试了好几种mdLocale.formatDate和parseDate使用瞬间..
鉴于
<md-datepicker ng-model="Model.currentContact.getSetIncorporated" ng-model-options="{ getterSetter: true }" md-placeholder="Enter date"></md-datepicker>
。目前的版本是
$mdDateLocale.formatDate = function(date) {
return moment(date).format('YYYY/MM/DD');
};
$mdDateLocale.parseDate = function(dateString) {
var m = moment(dateString, 'YYYY/MM/DD', true);
return m.isValid() ? m.toDate() : new Date(NaN);
};
当我说字符串转换为新的日期()Date对象的服务器发送该字符串2016-09-10T22:00:00.000Z
,我得到了mdDatePicker出正确的结果,但我得到的也 Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
这刹车我的页面。
我知道这是一个字符串...我甚至尝试转换该字符串与新的日期(stringDate),但得到无限的摘要循环错误。 – Alexa
'未捕获错误:[$ rootScope:infdig] 10 $ digest()迭代到达。放弃!' – Alexa
@Alexa - 您可能想补充说,您的问题可能是主要问题。 –