I am struggling with implementing 2 datepickers using Angular UI version 0.11.0.
Here is my HTML code:
<span ng-if="periods.period == 10">
<input type="text" datepicker-popup="dd-MMMM-yyyy" ng-model="cdate.customStartDate" is-open="opened1" max-date="maxDate" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" class="input-md" />
<button class="btn" ng-click="open($event,'opened1')"><span class="glyphicon glyphicon-calendar"></span></button>
</span>
<span ng-if="periods.period == 10">
<input type="text" datepicker-popup="dd-MMMM-yyyy" ng-model="cdate.customEndDate" is-open="opened2" min-date="cdate.customStartDate" max-date="maxDate" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" class="input-md" />
<button class="btn" ng-click="open($event,'opened2')"><span class="glyphicon glyphicon-calendar"></span></button>
</span>
And my JS code includes:
$scope.disabled = function(date, mode) {
return (mode === 'day' && (date.getDay() === -1 || date.getDay() === 7));
};
$scope.maxDate = new Date();
$scope.open = function ($event, opened) {
$event.preventDefault();
$event.stopPropagation();
$scope[opened] = true;
};
$scope.dateOptions = {
'year-format': "'yy'",
'starting-day': 1
};
Initially, the datepicker opens correctly when clicking the button. However, after the first opening, the issue arises where the datepicker popup fails to open upon subsequent clicks on the button.