2

I am using the angular-ui bootstrap datepicker component. on one view where I have two date fields, the datepicker opens up and after closed it opens up again when clicked fine.

On another page, after once opened and closed, the datepicker does not open up anymore.

Surely I'm missing something here, but I gave up after hours of trying to find it.

Can you help ?

the HTML section of the datepicker looks as follows:

<div class="input-group">
                        <input type="text" class="input-sm-7" datepicker-popup="dd/MM/yyyy" is-open="opened"
                               datepicker-options="dateOptions" ng-model="singleDate"
                               close-text="Close" />
                        <button type="button" class="btn btn-default" ng-click="open($event)"><i
                                class="fa fa-calendar"></i>
                        </button>
                    </div>

The JS code in the controller looks like this:

            $scope.dateOptions = {
            formatYear: 'yy',
            startingDay: 1
        };

        $scope.open = function($event) {
            $event.preventDefault();
            $event.stopPropagation();

            $scope.opened = true;
        };

1 Answer 1

5

This is a known issue and there is a hack for it. Try this.

$scope.datePicker = {};
$scope.open = function ($event) {
  $event.preventDefault();
  $event.stopPropagation();
  $scope.datePicker.opened = true;
};

Change in the Html

<div class="input-group">
  <input type="text" class="input-sm-7" datepicker-popup="dd/MM/yyyy" is-open="datePicker.opened"
                               datepicker-options="dateOptions" ng-model="singleDate"
                               close-text="Close" />
  <button type="button" class="btn btn-default" ng-click="open($event)"><i
                                class="fa fa-calendar"></i>
                        </button>
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

what cause this problem ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.