diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index c995dad9f3..a4579873c5 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -261,8 +261,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.position']) appendToBody: false }) -.directive('datepickerPopup', ['$compile', '$parse', '$document', '$position', 'dateFilter', 'datepickerPopupConfig', -function ($compile, $parse, $document, $position, dateFilter, datepickerPopupConfig) { +.directive('datepickerPopup', ['$compile', '$parse', '$document', '$position', 'dateFilter', 'datepickerPopupConfig', 'datepickerConfig', +function ($compile, $parse, $document, $position, dateFilter, datepickerPopupConfig, datepickerConfig) { return { restrict: 'EA', require: 'ngModel', @@ -406,7 +406,7 @@ function ($compile, $parse, $document, $position, dateFilter, datepickerPopupCon if (attrs.showWeeks) { addWatchableAttribute(attrs.showWeeks, 'showWeeks', 'show-weeks'); } else { - scope.showWeeks = true; + scope.showWeeks = datepickerConfig.showWeeks; datepickerEl.attr('show-weeks', 'showWeeks'); } if (attrs.dateDisabled) { diff --git a/src/datepicker/test/datepicker.spec.js b/src/datepicker/test/datepicker.spec.js index c1757869a0..af69093103 100644 --- a/src/datepicker/test/datepicker.spec.js +++ b/src/datepicker/test/datepicker.spec.js @@ -1259,6 +1259,30 @@ describe('datepicker directive', function () { expect(elm.children().length).toEqual(1); }); }); + + describe('with setting datepickerConfig.showWeeks to false', function() { + var originalConfig = {}; + beforeEach(inject(function(datepickerConfig) { + angular.extend(originalConfig, datepickerConfig); + datepickerConfig.showWeeks = false; + + var wrapElement = $compile('
')($rootScope); + $rootScope.$digest(); + assignElements(wrapElement); + })); + afterEach(inject(function(datepickerConfig) { + // return it to the original state + angular.extend(datepickerConfig, originalConfig); + })); + + it('changes initial visibility for weeks', function() { + expect(getLabelsRow().find('th').eq(0).css('display')).toBe('none'); + var tr = element.find('tbody').find('tr'); + for (var i = 0; i < 5; i++) { + expect(tr.eq(i).find('td').eq(0).css('display')).toBe('none'); + } + }); + }); }); });