Closed zeng-ge closed 5 years ago
same issue here
The following is a fix for this issue. Basically, put an empty object at the beginning of the array of objects to extend, so that you're not overwriting dateRangePickerConfig:
_mergeOpts = function() {
var extend, localeExtend;
var locales = Array.prototype.slice.call(arguments).map(function(opt) {
return opt != null ? opt.locale : void 0;
}).filter(function(opt) {
return !!opt;
});
locales.splice(0, 0, {});
localeExtend = angular.extend.apply(angular, locales);
extend = angular.extend.apply(angular, arguments);
extend.locale = localeExtend;
return extend;
};
Sorry it's a comment and not a PR. It's late, and I'm not that familiar with coffee script.
the first locale: { format: 'MM-DD-YYYY h:mm' } the second locale: { format: 'MM-DD-YYYY' } result: the first format will be overridden.
why _mergeOpts function merge customOpts's locale configuration to the constant dateRangePickerConfig.locale?
_mergeOpts = function() { var extend, localeExtend; localeExtend = angular.extend.apply(angular, Array.prototype.slice.call(arguments).map(function(opt) { return opt != null ? opt.locale : void 0; }).filter(function(opt) { return !!opt; })); extend = angular.extend.apply(angular, arguments); extend.locale = localeExtend; return extend; }; el = $(element); customOpts = $scope.opts; opts = _mergeOpts({}, dateRangePickerConfig, customOpts);