HFA HFA - 1 month ago 6
AngularJS Question

how to set uib-datepicker-popup opens always in day mode?

I have this issue with

uib-datepicker-popup
that when users opens the date picker and goes to month or year mode and closes the picker,and opens the date picker again, the picker opens in the last mode it was before being closed. How can I change behavior of
uib-datepicker-popup
to open in day mode always?

One option that I found was to set both
minMode
and
maxMode
to
day
, but doing so will prevent user from going to other modes which I don't want!

any idea is appreciated!

Here is a plunk to get you going: Demo

Answer

Probably the easiest way would be to force to set date picker mode before the popup is getting displayed. In that case there is no need to specify datepicker-options="{minMode: 'day', maxMode: 'day'}" that will prevent the user from choosing another modes.

So, set datepickerMode on popup click event:

$scope.open1 = function() {
  $scope.dateOptions.datepickerMode = 'day'; //<-force to set date picker mode
  $scope.popup1.opened = true;
};

Updated demo