【发布时间】:2015-09-03 11:20:31
【问题描述】:
在我的科尔多瓦项目中,为科尔多瓦日期选择器插件cordova-plugin-datepicker 设置自定义日期时遇到问题。但它只显示当前日期。
例如:
var options = {
date: new Date('12/12/2015'),
mode: 'datetime', // or 'time'
minDate : moment().subtract(100, 'years').toDate(),
allowOldDates: true,
allowFutureDates: true,
androidTheme : 2,
doneButtonLabel: 'DONE',
doneButtonColor: '#000000',
cancelButtonLabel: 'CANCEL',
cancelButtonColor: '#000000'
};
$ionicPlatform.ready(function() {
$cordovaDatePicker.show(options)
.then(function(date){
$scope.appointmentVM.dateFrom = new Date(date).valueOf().toString();
});
});
在这里您可以看到new Date('12/12/2015') 已设置,但它会在选择器中显示当前日期而不是设置日期。
你能帮忙吗?
更新: 我得到了解决方案:
我们必须在日期选项中如下设置 minDate。会解决问题的
minDate : ionic.Platform.isIOS() ? moment().subtract(100,'years').toDate() : moment().subtract(100,'years').valueOf(),
【问题讨论】: