HFA HFA - 1 year ago 108
AngularJS Question

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

I have this issue with

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
to open in day mode always?

One option that I found was to set both
, 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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download