[英]Display Short week days in angular-bootstrap-calendar instead of long week days
我在 Angular 4 應用程序中使用angular-bootstrap-calendar ,它會顯示較長的工作日(例如:星期日、星期一等...)。 相反,我想要有 2 個字母的短工作日(例如:Su、Mo 等...)。 它有任何預定義的 class 可以直接在我的應用程序中使用嗎?
在我找到答案之前找到了這個線程(3 個而不是 2 個字母,但比整個工作日更好)所以我把它留給下一個人:
模塊開發者的回答:
但是重寫 monthViewColumnHeader 方法
import {CalendarNativeDateFormatter, DateFormatterParams, CalendarModule} from 'angular2-calendar';
class CustomDateFormatter extends CalendarNativeDateFormatter {
public monthViewColumnHeader({date, locale}: DateFormatterParams): string {
return new Intl.DateTimeFormat(locale, {weekday: 'short'}).format(date);
}
}
@NgModule({
import: [CalendarModule],
providers: [
CalendarEventTitleProvider,
{provide: CalendarDateFormatter, useClass: CustomDateFormatter}
]
})
class ModuleThatUsesTheCalendar{}
替代 2 個字母
如果這不起作用,請從您想要的模塊中獲取默認模板並進行更改
<b>{{ day.date | calendarDate : 'weekViewColumnHeader' : locale }}</b
到
<b>{{ day.date | date:'EEEEE':undefined:'en'}}</b><br />
// angular datepipe date:'format':timezone:'locale'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.