Hello, sorry if its maybe a basic question. The field below when clicked shows a date picker.
http://ngcordova.com/docs/plugins/datePicker/
<input type="text" placeholder="Data" ng-disabled="buttonDisabled" ng-model="displayedSearchDate" ng-click="showDatePicker()"
The problem is that clicking fast multiple times on it will launch multiple istances of the datepicker.
I tried disabling the field after the first click but when the datetime picker shows up, if the user clicks the cancel button the field remains in the disabled state. I was not able to find how to hook in this “cancel button” event on the datepicker plugin.
$scope.showDatePicker = function () {
$scope.buttonDisabled = true;
var datePickerOptions = {
date: new Date(),
mode: 'date', // or 'time'
minDate: moment().subtract(100, 'years').toDate(),
allowOldDates: true,
allowFutureDates: true,
doneButtonLabel: 'DONE',
doneButtonColor: '#F2F3F4',
cancelButtonLabel: 'CANCEL',
cancelButtonColor: '#000000'
};
$ionicPlatform.onHardwareBackButton(function () {
$scope.buttonDisabled = false;
});
$cordovaDatePicker.show(datePickerOptions).then(function (date) {
$scope.buttonDisabled = false;
$scope.displayedSearchDate = moment(date).format('ddd D MMMM');
$scope.when.searchDate = moment(date).format('YYYY-MM-DD');
}, false);
}
Any help / hint is very appreciated!
Fabio