2016-04-06 119 views
0

我正在開發Web服務。但我不知道如何使用Angularjs設置bs-datepicker的語言。這是英文版,但我想將其更改爲'kr'。我該怎麼辦?如何更改bs-datepicker的語言

<input type="text" class="form-control 
text-center"data-date-format="yyyy-MM-dd" bs-datepicker> 

enter image description here

+0

這是所有在[文檔]解釋(http://bootstrap-datepicker.readthedocs.org/en/latest/i18n.html) – Matheno

回答

0

而且@Matheno評論,你可以通過創建 「語言」 對象做到這一點。

喜歡的東西:

$.fn.datepicker.dates['en'] = { 
    days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], 
    daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 
    daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 
    months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], 
    monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], 
    today: "Today", 
    clear: "Clear", 
    format: "mm/dd/yyyy", 
    titleFormat: "MM yyyy", /* Leverages same syntax as 'format' */ 
    weekStart: 0 
}; 

具體,爲kr您可以使用下面的腳本。

https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.0/locales/bootstrap-datepicker.kr.min.js 
  1. 添加這個腳本到您的網頁。
  2. 設置語言,當你初始化插件
$('.datepicker').datepicker({ 
    language: 'kr' 
}); 

對於具體指令bs-datepicker您可以添加在.config節這個選項。

像這樣:

angular.module('myApp') 
.config(function($datepickerProvider) { 
    angular.extend($datepickerProvider.defaults, { 
    language: 'kr' 
    }); 
})