diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js
index ed7e7537ad..1f054adda6 100644
--- a/src/datepicker/datepicker.js
+++ b/src/datepicker/datepicker.js
@@ -17,13 +17,12 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
ngModelOptions: {},
shortcutPropagation: false,
showWeeks: true,
- startingDay: 0,
yearColumns: 5,
yearRows: 4
})
-.controller('UibDatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerSuppressError', 'uibDateParser',
- function($scope, $attrs, $parse, $interpolate, $log, dateFilter, datepickerConfig, $datepickerSuppressError, dateParser) {
+.controller('UibDatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$locale', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerSuppressError', 'uibDateParser',
+ function($scope, $attrs, $parse, $interpolate, $locale, $log, dateFilter, datepickerConfig, $datepickerSuppressError, dateParser) {
var self = this,
ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl;
ngModelOptions = {};
@@ -37,10 +36,19 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
});
// Evaled configuration attributes
- angular.forEach(['showWeeks', 'startingDay', 'yearRows', 'yearColumns', 'shortcutPropagation'], function(key) {
- self[key] = angular.isDefined($attrs[key]) ? $scope.$parent.$eval($attrs[key]) : datepickerConfig[key];
+ angular.forEach(['showWeeks', 'yearRows', 'yearColumns', 'shortcutPropagation'], function(key) {
+ self[key] = angular.isDefined($attrs[key]) ?
+ $scope.$parent.$eval($attrs[key]) : datepickerConfig[key];
});
+ if (angular.isDefined($attrs.startingDay)) {
+ self.startingDay = $scope.$parent.$eval($attrs.startingDay);
+ } else if (angular.isNumber(datepickerConfig.startingDay)) {
+ self.startingDay = datepickerConfig.startingDay;
+ } else {
+ self.startingDay = ($locale.DATETIME_FORMATS.FIRSTDAYOFWEEK + 8) % 7;
+ }
+
// Watchable date attributes
angular.forEach(['minDate', 'maxDate'], function(key) {
if ($attrs[key]) {
diff --git a/src/datepicker/docs/readme.md b/src/datepicker/docs/readme.md
index b613be0633..1733aea7c6 100644
--- a/src/datepicker/docs/readme.md
+++ b/src/datepicker/docs/readme.md
@@ -97,7 +97,7 @@ The datepicker has 3 modes:
$
-
The date object. Needs to be a Javascript Date object.
-
+
* `ng-model-options`
$
C
@@ -121,7 +121,7 @@ The datepicker has 3 modes:
* `starting-day`
$
C
- _(Default: `0`)_ -
+ _(Default: `$locale.DATETIME_FORMATS.FIRSTDAYOFWEEK`)_ -
Starting day of the week from 0-6 (0=Sunday, ..., 6=Saturday).
* `template-url`
@@ -176,7 +176,7 @@ The popup is a wrapper that you can use in an input to toggle a datepicker. To c
C
_(Default: `false`, Config: `appendToBody`)_ -
Append the datepicker popup element to `body`, rather than inserting after `datepicker-popup`.
-
+
* `datepicker-options`
$ -
An object with any combination of the datepicker settings (in camelCase) used to configure the wrapped datepicker.
@@ -208,7 +208,7 @@ The popup is a wrapper that you can use in an input to toggle a datepicker. To c
C
_(Default: `true`)_ -
Whether or not to display a button bar underneath the uib-datepicker.
-
+
* `type`
C
_(Default: `text`, Config: `html5Types`)_ -
diff --git a/src/datepicker/test/datepicker.spec.js b/src/datepicker/test/datepicker.spec.js
index d863666007..2ee9e7b1b2 100644
--- a/src/datepicker/test/datepicker.spec.js
+++ b/src/datepicker/test/datepicker.spec.js
@@ -1223,6 +1223,9 @@ describe('datepicker', function() {
}));
afterEach(inject(function(uibDatepickerConfig) {
// return it to the original state
+ Object.keys(uibDatepickerConfig).forEach(function(key) {
+ delete uibDatepickerConfig[key];
+ });
angular.extend(uibDatepickerConfig, originalConfig);
}));