Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Fixed wrong param name dateFormat in datepickerPopupConfig #1810

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.position'])
})

.constant('datepickerPopupConfig', {
dateFormat: 'yyyy-MM-dd',
datepickerPopup: 'yyyy-MM-dd',
currentText: 'Today',
clearText: 'Clear',
closeText: 'Done',
Expand Down Expand Up @@ -328,7 +328,7 @@ function ($compile, $parse, $document, $position, dateFilter, datepickerPopupCon
};

attrs.$observe('datepickerPopup', function(value) {
dateFormat = value || datepickerPopupConfig.dateFormat;
dateFormat = value || datepickerPopupConfig.datepickerPopup;
ngModel.$render();
});

Expand Down
28 changes: 27 additions & 1 deletion src/datepicker/test/datepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,32 @@ describe('datepicker directive', function () {

});

describe('setting datepickerPopupConfig', function() {
var originalConfig = {};
beforeEach(inject(function(datepickerPopupConfig) {
angular.extend(originalConfig, datepickerPopupConfig);
datepickerPopupConfig.datepickerPopup = 'MM-dd-yyyy';
datepickerPopupConfig.currentText = 'Today';
datepickerPopupConfig.clearText = 'Clear';
datepickerPopupConfig.closeText = 'Done';
datepickerPopupConfig.closeOnDateSelection = true;
datepickerPopupConfig.appendToBody = false;
datepickerPopupConfig.showButtonBar = true;

element = $compile('<input ng-model="date" datepicker-popup>')($rootScope);
$rootScope.$digest();
}));
afterEach(inject(function(datepickerPopupConfig) {
// return it to the original state
angular.extend(datepickerPopupConfig, originalConfig);
}));

it('changes date format', function() {
expect(element.val()).toEqual('09-30-2010');
});

});

describe('as popup', function () {
var inputEl, dropdownEl, changeInputValueTo, $document;

Expand All @@ -810,7 +836,7 @@ describe('datepicker directive', function () {
};
}));

it('to display the correct value in input', function() {
it('displays the correct value as yyyy-MM-dd by default', function() {
expect(inputEl.val()).toBe('2010-09-30');
});

Expand Down