1

Is there a way to provide datepicker-options in ui.bootstrap.datepickerPopup in the HTML instead of creating a separate object for each datepicker?

The original documentation says

to configure the uib-datepicker you need to create an object in Javascript with all the options and use it on the datepicker-options attribute

However, I have almost 40 different datepickers on a page. And I have to provide min and max dates dynamically.

Earlier versions (ui-bootstrap-tpls-0.13.4.js) of datepicker, I could use max-date or min-date attribute with some ng-model value on the input element itself. Now do I have to create a JS object for each datepicker-options? Is there a way to achieve this?

3
  • 2
    you can write the options inline, on the html iteself Commented Sep 6, 2016 at 19:03
  • sometimes your brain stops working like it is supposed to. thanks svarog. (y) Commented Sep 7, 2016 at 18:41
  • 1
    only sometimes? you're a lucky guy! Commented Sep 7, 2016 at 18:47

1 Answer 1

3

As mentioned in comments by @savrog, I just added the date-picker options in HTML as follows:

<input datepicker-options="{minDate: MyMinDate}" type="text" class="form-control" uib-datepicker-popup="MM/dd/yyyy" ng-model="vm.dDischargeDateFormatted" is-open="dDischargeDateFormatted" ng-required="false" close-text="Close" alt-input-formats="altInputFormats"/>
     <span class="input-group-btn">
             <button type="button" class="btn btn-default" ng-click="dDischargeDateFormatted=true"><i class="glyphicon glyphicon-calendar"></i></button>
     </span>
Sign up to request clarification or add additional context in comments.

Comments

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.