如何全局配置Angular UI引导程序指令



如何全局使用uibDatepickerConfig配置引导程序日期选择器?文件上只写了以下内容:

所有设置可以在uib-datepicker中作为属性提供,也可以通过uibDatepickerConfig全局配置。

在源代码中,它们被定义为常量:

.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
})

这篇文章已经讨论了完全相同的问题,但解决方案似乎已经过时了。

//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';
}]);

最新更新