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

Commit

Permalink
fix(datepicker): rename dateFormat to datepickerPopup in datepick…
Browse files Browse the repository at this point in the history
…erPopupConfig

Closes #1810
  • Loading branch information
rafbgarcia authored and bekos committed Feb 27, 2014
1 parent 467dd15 commit 93da30d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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
20 changes: 20 additions & 0 deletions src/datepicker/test/datepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,26 @@ describe('datepicker directive', function () {

});

describe('setting datepickerPopupConfig', function() {
var originalConfig = {};
beforeEach(inject(function(datepickerPopupConfig) {
angular.extend(originalConfig, datepickerPopupConfig);
datepickerPopupConfig.datepickerPopup = 'MM-dd-yyyy';

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 Down

0 comments on commit 93da30d

Please sign in to comment.