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

Commit

Permalink
feat(datepicker): pass options from popup to inline
Browse files Browse the repository at this point in the history
- Pass through options object wholesale from popup to inline datepicker

Closes #5355

BREAKING CHANGE: This breaks any snake-cased key usage, i.e.
`show-weeks`. Convert all keys used to camelCase.
  • Loading branch information
wesleycho committed Feb 1, 2016
1 parent d88c0fb commit 3e10184
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,14 +767,11 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi
}

if (scope.datepickerOptions) {
angular.forEach(scope.datepickerOptions, function(value, option) {
// Ignore this options, will be managed later
if (['minDate', 'maxDate', 'minMode', 'maxMode', 'initDate', 'datepickerMode'].indexOf(option) === -1) {
datepickerEl.attr(cameltoDash(option), value);
} else {
datepickerEl.attr(cameltoDash(option), 'datepickerOptions.' + option);
}
});
datepickerEl.attr('datepicker-options', 'datepickerOptions');

if (angular.isDefined(scope.datepickerOptions.datepickerMode)) {
datepickerEl.attr('datepicker-mode', 'datepickerOptions.datepickerMode');
}
}

angular.forEach(['minMode', 'maxMode', 'datepickerMode', 'shortcutPropagation'], function(key) {
Expand Down
4 changes: 2 additions & 2 deletions src/datepicker/test/datepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ describe('datepicker', function() {
describe('show-weeks', function() {
beforeEach(function() {
$rootScope.opts = {
'show-weeks': false
showWeeks: false
};
var wrapElement = $compile('<div><input ng-model="date" uib-datepicker-popup datepicker-options="opts" is-open="true"></div>')($rootScope);
$rootScope.$digest();
Expand All @@ -2123,7 +2123,7 @@ describe('datepicker', function() {
beforeEach(function() {
$rootScope.date = null;
$rootScope.opts = {
'initDate': new Date('November 9, 1980')
initDate: new Date('November 9, 1980')
};
var wrapElement = $compile('<div><input ng-model="date" uib-datepicker-popup datepicker-options="opts" is-open="true"></div>')($rootScope);
$rootScope.$digest();
Expand Down

0 comments on commit 3e10184

Please sign in to comment.