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

Commit ed133c6

Browse files
authored
Setting selected date on first time load
When datepicker opens first time, the selectedDay, selectedMonth and selectedYear are not initialised, which prevent the active class from being applied. This works on subsequent opens though once setDatepickerDay is called.
1 parent 027d596 commit ed133c6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/js/angular-datepicker.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@
348348
if (theCalendar.classList) {
349349

350350
theCalendar.classList.add('_720kb-datepicker-open');
351+
var dateString = angular.element((angular.element(theCalendar).parent()[0]).querySelector('input')).val();
352+
var date = new Date(dateString);
353+
$scope.selectedMonth = Number($filter('date')(date, 'MM'));
354+
$scope.selectedDay = Number($filter('date')(date, 'dd'));
355+
$scope.selectedYear = Number($filter('date')(date, 'yyyy'));
351356
} else {
352357

353358
classHelper.add(theCalendar, '_720kb-datepicker-open');

0 commit comments

Comments
 (0)