2015-11-03 43 views
3

如何在全局範圍內使用uibDatepickerConfig配置bootstrap datepicker?該文檔只是說:如何全局配置Angular UI引導程序僞指令

所有設置可以作爲屬性提供在uib-datepicker或全局配置通過uibDatepickerConfig

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已討論,但解決方案似乎過時

+0

您是否嘗試過該解決方案? –

+0

@PetrAveryanov是的,我有。由於它們不使用*提供程序*,因此它不再工作(已經不再)。也許這在去年發生了變化。 – DonJuwe

+1

http://plnkr.co/edit/NpS0QtA88ZBzxBQMXfIE?p=preview(僅作爲角度引導頁面的示例)在該解決方案中工作(只是添加'uib'來命名) –

回答

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

這似乎不起作用... –

+0

任何日誌中的錯誤/異常? –

+0

未定義uibDatepickerConfig。您錯過了該變量的注入。 –

相關問題