zhaber / ng-bootstrap-datetimepicker

:calendar::clock2: Angular Bootstrap Date Time Picker
MIT License
149 stars 57 forks source link

Problem with min-date #104

Closed Hypocrite closed 8 years ago

Hypocrite commented 8 years ago

I have a weird problem with the min-date attribute and the datepicker popup.

I am trying to set it to null but it always tries to disable all past dates in the datepicker popup when there is a date in the ng-model.

If I manually change the date to some past date, it works fine. But then the datepicker popup disables are dates past that date.

I have tried to reproduce this in Plunker without luck. Any help or tips?

My bower.json looks like this: "dependencies": { "angular": "~1.5.0", "angular-animate": "~1.5.0", "angular-bootstrap": "^1.3.2", "angular-bootstrap-calendar": "~0.18.8", "angular-dynamic-locale": "~0.1.27", "angular-filter": "~0.5.4", "angular-gettext": "2.1.0", "angular-i18n": "~1.3.16", "angular-load": "~0.2.0", "angular-local-storage": "~0.2.2", "angular-messages": "~1.3.16", "angular-order-object-by": "~1.1.1", "angular-resource": "~1.4.0", "angular-route": "1.3.16", "angular-smart-table": "~2.1.2", "angular-ui-bootstrap-datetimepicker": "~1.2.4", "angular-ui-router": "~0.2.17", "angular-utils-pagination": "", "angularjs-dropdown-multiselect": "~1.5.2", "bower": "", "components-font-awesome": "~4.3.0", "install": "~1.0.4", "moment": "2.10.3", "ng-file-upload": "~7.0.10", "ng-sortable": "~1.1.9", "ngImgCrop": "~0.3.2", "ngstorage": "~0.3.0", "oi.multiselect": "~0.1.7", "oi.select": "0.2.16", "tc-angular-chartjs": "~1.0.13", "chart.horizontalbar": "~1.0.3", "angular-responsive-tables": "~0.1.3", "moment-duration-format": "~1.3.0", "angular-spinner": "^0.8.1", "angular-bootstrap-lightbox": "^0.12.0" },

zhaber commented 8 years ago

Try to use the same libraries as used at http://plnkr.co/edit/HyGjgy?p=preview We will need to be able to reproduce the issue to root cause it, so if by any chance you can create a plunker let us know.

Hypocrite commented 8 years ago

I think I figured the root cause.

The situation is that I have a start date and end date in the page. And I would like to set the start date as the minimum date for the end date. But if I set the attribute min-date to startDate for the end date picker it will also affect the start date picker. Is there someway I could set the end date minimum to be start date without it affecting the start date? User should not be able to select an end date which is before the start date.

I made a plunker about it: http://plnkr.co/edit/k7qBpw67dn4yQ53pJBkU?p=preview

zhaber commented 8 years ago

internally min date is set via dateOptions, which is shared between two options in your case, so the workaround should be to not share the same dateOptions object. I removied min-date/max-date attributes in accordance to what is done in the underlying angular ui date directive (dateOptions.minDate/maxDate attributes should be used instead).

https://github.com/zhaber/angular-js-bootstrap-datetimepicker/commit/c599a8ff2cb1489ff094b12ec022a932d416c76b

New demo plunkr: http://plnkr.co/edit/HyGjgy?p=preview