如何在全局范围内使用 uibDatepickerConfig
配置 bootstrap datepicker?该文档仅说明以下内容:
在 source code 中,它们被定义为常量:
.constant('uibDatepickerConfig', {
formatDay: 'dd',
formatMonth: 'MMMM',
formatYear: 'yyyy',
formatDayHeader: 'EEE',
formatDayTitle: 'MMMM yyyy',
formatMonthTitle: 'yyyy',
datepickerMode: 'day',
minMode: 'day',
maxMode: 'year',
showWeeks: true,
startingDay: 0,
yearRange: 20,
minDate: null,
maxDate: null,
shortcutPropagation: false
})
this post 中已经讨论了完全相同的问题,但解决方案似乎是 过时的 。
最佳答案
//where app is the module that depends on 'ui.bootstrap'
// probably your main app module
//for DatePicker options
app.config(['uibDatepickerConfig', function (uibDatepickerConfig) {
uibDatepickerConfig.showWeeks = false;
}]);
//for DatePickerPopup options
app.config(['uibDatepickerPopupConfig', function (uibDatepickerPopupConfig) {
uibDatepickerPopupConfig.closeText= 'Close';
uibDatepickerPopupConfig.placement = 'auto bottom';
}]);