离子日期时间选择器仅显示日期(ng-cordova)
ionic Date time picker show only the date (ng-cordova)
我正在使用离子框架开发网络应用程序。在这个应用程序中,我需要一个日期时间选择器,所以我安装了 ng-cordova datepicker 插件,在 android 设备上它工作正常但在 ios 设备上我只得到没有时间的日期这是我的代码:
var options_date = {
date: new Date(),
mode: 'datetime', // or 'time'
minDate: new Date() - 10000,
allowOldDates: true,
allowFutureDates: true,
doneButtonLabel: 'DONE',
doneButtonColor: '#F2F3F4',
cancelButtonLabel: 'CANCEL',
cancelButtonColor: '#000000'
};
$scope.setDate = function() {
$cordovaDatePicker.show(options_date).then(function(date){
$scope.startDateTime = date;
});
};
感谢您的帮助
你能用这段代码检查一下它对我有用吗:
在 index.html 中创建一个按钮
<ion-content ng-controller="ExampleCtrl">
<button class="button button-bar button-balanced" ng-click="datePick()">Check It</button>
</ion-content>
在您的控制器中将函数代码写为:
.controller('ExampleCtrl', ['$scope','$ionicPlatform','$cordovaDatePicker', function ($scope,$ionicPlatform,$cordovaDatePicker) {
$scope.datePick = function(){
var options = {
date: new Date(),
mode: 'datetime', // or 'time'
minDate: new Date() - 10000,
allowOldDates: true,
allowFutureDates: false,
doneButtonLabel: 'DONE',
doneButtonColor: '#F2F3F4',
cancelButtonLabel: 'CANCEL',
cancelButtonColor: '#000000'
}
$ionicPlatform.ready(function(){
$cordovaDatePicker.show(options).then(function(date){
alert(date);
});
})
}
}])
Android 浏览器不支持(目前)datetime
HTML5 输入类型。
README page of the plugin 还说 datetime
仅适用于 iOs 和 Windows。
您可以使用
mode: 'date'
和
mode: 'time'
在 2 中控制并从两个值中收集日期时间。
我正在使用离子框架开发网络应用程序。在这个应用程序中,我需要一个日期时间选择器,所以我安装了 ng-cordova datepicker 插件,在 android 设备上它工作正常但在 ios 设备上我只得到没有时间的日期这是我的代码:
var options_date = {
date: new Date(),
mode: 'datetime', // or 'time'
minDate: new Date() - 10000,
allowOldDates: true,
allowFutureDates: true,
doneButtonLabel: 'DONE',
doneButtonColor: '#F2F3F4',
cancelButtonLabel: 'CANCEL',
cancelButtonColor: '#000000'
};
$scope.setDate = function() {
$cordovaDatePicker.show(options_date).then(function(date){
$scope.startDateTime = date;
});
};
感谢您的帮助
你能用这段代码检查一下它对我有用吗:
在 index.html 中创建一个按钮
<ion-content ng-controller="ExampleCtrl">
<button class="button button-bar button-balanced" ng-click="datePick()">Check It</button>
</ion-content>
在您的控制器中将函数代码写为:
.controller('ExampleCtrl', ['$scope','$ionicPlatform','$cordovaDatePicker', function ($scope,$ionicPlatform,$cordovaDatePicker) {
$scope.datePick = function(){
var options = {
date: new Date(),
mode: 'datetime', // or 'time'
minDate: new Date() - 10000,
allowOldDates: true,
allowFutureDates: false,
doneButtonLabel: 'DONE',
doneButtonColor: '#F2F3F4',
cancelButtonLabel: 'CANCEL',
cancelButtonColor: '#000000'
}
$ionicPlatform.ready(function(){
$cordovaDatePicker.show(options).then(function(date){
alert(date);
});
})
}
}])
Android 浏览器不支持(目前)datetime
HTML5 输入类型。
README page of the plugin 还说 datetime
仅适用于 iOs 和 Windows。
您可以使用
mode: 'date'
和
mode: 'time'
在 2 中控制并从两个值中收集日期时间。