Disable Angular ui.bootstrap.datepicker

user2964500 picture user2964500 · Jul 2, 2014 · Viewed 15.1k times · Source

I'm using the datepicker in the Angular bootstrap collection. (http://angular-ui.github.io/bootstrap/).

I know that you can disable individual dates in the datepicker, but I need to disable the whole datepicker, as shown in this blog post (which uses jQuery).

How would you disable the whole datepicker using Angular?

Answer

Fedor Skrynnikov picture Fedor Skrynnikov · Jul 2, 2014

It seems there is no way of doing this directly. But there are some workarounds which were discussed in https://github.com/angular-ui/bootstrap/issues/1113

Instead you can make a scope variable that will indicate if datepicker is disabled and if yes, then hide datepiker at all and show the model of datepicker in a fancy container.

Other way is to set date-disabled to true, disable input and set show-button-bar to false.

But again...those are workarounds ... you may try to make them look prettier by wraping to the custom directive like datepicker-disable if you want. Or wrap jquery datepicker you like into angular directive, which will be a bit more work.