Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit 1e3fd0d

Browse files
committed
atm there is a problem with scope.year updates
1 parent 4a0231f commit 1e3fd0d

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ date-max-limit="" | String | false | Set a maximum date limit - you can use all
8383
date-set-hidden="" | String(Boolean) | false | Set the default date to be shown only in calendar and not in the input field
8484
date-disabled-dates="" | String([Date(), Date(), ...]) | false | Disable specific dates using an _Array_ of dates
8585
date-refocus="" | String(Boolean) | false | Set the datepicker to re-focus the input after selecting a date
86-
86+
date-typer="" | String(Boolean) | false | Set the datepicker to update calendar when is user typing a date
87+
8788
##Options
8889
Angular datepicker allows you to use some options via `attribute` data
8990

src/js/angular-datepicker.js

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,11 @@
446446

447447
$scope.day = Number(day);
448448
setInputValue();
449-
449+
450450
if (attr.hasOwnProperty('dateRefocus')) {
451451
thisInput[0].focus();
452452
}
453-
453+
454454
$scope.hideCalendar();
455455
}
456456
};
@@ -483,7 +483,42 @@
483483

484484
theNewYears.push(Number(startingYear) + i);
485485
}
486+
//date typing in input date-typer
487+
if ($scope.dateTyper) {
488+
489+
thisInput.on('keyup', function onTyping() {
490+
491+
if (thisInput[0].value &&
492+
thisInput[0].value.length &&
493+
thisInput[0].value.length > 0) {
494+
495+
try {
496+
497+
date = new Date(thisInput[0].value.toString());
498+
499+
if (date.getFullYear() &&
500+
date.getDay() &&
501+
date.getMonth() &&
502+
$scope.isSelectableDate(date) &&
503+
$scope.isSelectableMaxDate(date) &&
504+
$scope.isSelectableMinDate(date)) {
486505

506+
$scope.$apply(function applyTyping() {
507+
508+
$scope.month = $filter('date')(date, 'MMMM');//december-November like
509+
$scope.monthNumber = Number($filter('date')(date, 'MM')); // 01-12 like
510+
$scope.year = Number($filter('date')(date, 'yyyy'));//2014 like
511+
setDaysInMonth($scope.monthNumber, $scope.year);
512+
$scope.day = Number($filter('date')(date, 'dd')); //01-31 like
513+
});
514+
}
515+
} catch (e) {
516+
517+
return e;
518+
}
519+
}
520+
});
521+
}
487522
//check range dates
488523
if ($scope.dateMaxLimit &&
489524
theNewYears &&
@@ -674,7 +709,8 @@
674709
'buttonNextTitle': '@',
675710
'buttonPrevTitle': '@',
676711
'dateDisabledDates': '@',
677-
'dateSetHidden': '@'
712+
'dateSetHidden': '@',
713+
'dateTyper': '@'
678714
},
679715
'link': linkingFunction
680716
};

0 commit comments

Comments
 (0)