What a day I've been having... anyway, I have been assisting some colleagues with an AngularJS project and so much is wrong, anyway... I am using the AngularJS UI Bootstrap Datepicker version 0.11.2 with AngularJS version 1.3. So far so good however I wish to set the minimum date 2 months from the current day, the maximum date six months from the current day and the initial date 2 months from the current day. This is what I have so far:
View
<div data-datepicker
data-ng-model="dt"
data-min-date="minDate"
data-max-date="maxDate"
data-max-mode="day"
data-show-weeks="false"
data-starting-day="1"
data-year-range="2"
class="custom-date-picker"></div>
and in my controller...
var today = new Date(),
twoMonth = today.setMonth(today.getMonth() + 2),
sixMonth = today.setMonth(today.getMonth() + 6);
$scope.today = function() {
$scope.minDate = twoMonth;
$scope.maxDate = sixMonth;
};
$scope.today();
This is all find however I've noticed that minDate is correct, maxDate is actually 8 months in the future and when I add the following to the directive to set the initial date like so (notice data-init-date="minDate")
<div data-datepicker
data-ng-model="dt"
data-init-date="minDate"
data-min-date="minDate"
data-max-date="maxDate"
data-max-mode="day"
data-show-weeks="false"
data-starting-day="1"
data-year-range="2"
class="custom-date-picker"></div>
I get the following error!
TypeError: undefined is not a function
at e._refreshView (js/vendor/angular/ng-ui-bootstrap-tpls-0.11.2.min.js:8:16705)
at refreshView (js/vendor/angular/ng-ui-bootstrap-tpls-0.11.2.min.js:8:13968)
at link (js/vendor/angular/ng-ui-bootstrap-tpls-0.11.2.min.js:8:17848)
at B (js/vendor/angular/angular-1.3.0-beta.18.min.js:55:369)
at js/vendor/angular/angular-1.3.0-beta.18.min.js:62:378
at g (js/vendor/angular/angular-1.3.0-beta.18.min.js:48:105)
at js/vendor/angular/angular-1.3.0-beta.18.min.js:47:233
at js/vendor/angular/angular-1.3.0-beta.18.min.js:49:54
at Object.r [as transclude] (js/vendor/angular/angular-1.3.0-beta.18.min.js:52:497)
at js/vendor/angular/angular-1.3.0-beta.18.min.js:215:316 <table role="grid" aria-labelledby="{{uniqueId}}-title" aria-activedescendant="{{activeDateId}}" ng-switch-when="day" tabindex="0">
Does anyone know where I am going wrong?