Tôi đang nhận được lỗi này The ng-model for md-datepicker must be a Date instance. Currently the model is a: string
. Tôi đang sử dụng thời điểm ..
trong tầm nhìn
<md-datepicker ng-model="Model.currentContact.getSetIncorporated" ng-model-options="{ getterSetter: true }" md-placeholder="Enter date"></md-datepicker>
trong mô hình
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;
}
Ngoài ra, tôi đã thử một số mdLocale.formatDate và parseDate. Phiên bản hiện tại là
$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);
};
máy chủ đang gửi chuỗi này 2016-09-10T22:00:00.000Z
Khi tôi chuyển đổi chuỗi đó thành đối tượng Date với Date () mới, tôi nhận được kết quả hiển thị ngay trong mdDatePicker nhưng tôi cũng nhận được kết quả Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
phanh trang của mình.