Reputation: 1270
I'm trying to have a year picker using the angular-ui Bootstrap datepicker directive.
It works when it is inline, but not in the popup. Setting the options via datepicker-options doesn't matter for the popup.
See this Plunker: http://plnkr.co/edit/GRqSTCE7hOP6ZbBY3dZd
Why does this datepicker:
<datepicker ng-model="dt" datepicker-mode="'year'"
min-mode="year" min-date="minDate"
show-weeks="false" class="well well-sm"></datepicker>
behave differently than this:
<input type="text" class="form-control" ng-model="dt"
datepicker-mode="'year'"
min-mode="year" min-date="minDate"
show-weeks="false"
datepicker-popup="{{format}}" is-open="opened" ng-focus="open($event)"
date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" />
What am I missing?
Upvotes: 2
Views: 13630
Reputation: 8749
You have to use 'datepicker-options' attribute to pass in the options, rather than the element attributes. Consider the following: http://plnkr.co/edit/FJRsvwnjitOUsGor8ZRb?p=preview
<input type="text" class="form-control" ng-model="dt"
datepicker-popup="{{format}}" datepicker-options="{{datepickerOptions}}"
is-open="opened" ng-focus="open($event)"
date-disabled="disabled(date, mode)" ng-required="true" close-text="Close">
</input>
and
$scope.datepickerOptions = {
datepickerMode:"'year'",
minMode:"'year'",
minDate:"minDate",
showWeeks:"false",
};
Upvotes: 7