小时显示小时段角度日历 [英] Hour display hourSegments angular-calendar

查看:104
本文介绍了小时显示小时段角度日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的日历中,我需要显示每天和每周的时间,如下所示:09:00、09:15、09:20.

In my calendar I need to display the time of day and week as follows: 09:00, 09:15, 09:20.

我将软件包升级到了最新版本

I upgraded the package to the latest

angular-calendar version
0.26.1

现在下面的代码给出了错误,我无法再像以前那样显示时间.

and now the code below is giving error and I can no longer display the time as before.

module.ts:

class CustomDateFormatter extends CalendarNativeDateFormatter {
    public dayViewHour({ date, locale }: DateFormatterParams): string {
        return new Intl.DateTimeFormat('ca', {
            hour: 'numeric',
            minute: 'numeric'
        }).format(date);
    }
}
    // It does not work any more this way and error occurs ...
    CalendarModule.forRoot({
        dateFormatter: {
            provide: CalendarDateFormatter,
            useClass: CustomDateFormatter
        }
    }),

component.scss:

.cal-day-view .cal-hour-segment.cal-after-hour-start .cal-time {
    display: block;
  }

我在其他地方搜索过的文档,但找不到我需要的...

I looked in the documentation I searched elsewhere but could not find what I need ...

推荐答案

我通过彻底的文档阅读("angular-calendar":"^ 0.27.14")找到了答案. https://mattlewis92.github.io/angular-calendar/docs/modules/CalendarModule.html forRoot的签名是forRoot(dateAdapter:Provider,config:CalendarModuleConfig)

I've found the answer by thoroughly docs reading ("angular-calendar": "^0.27.14"). https://mattlewis92.github.io/angular-calendar/docs/modules/CalendarModule.html Signature of forRoot is forRoot(dateAdapter: Provider, config: CalendarModuleConfig)

所以这段代码对我有用(具有上面提到的样式),并且每个小时段都有时间.

So this code worked for me (with styling you mentioned above) and every hour segment has it's time.

    CalendarModule.forRoot({
      provide: DateAdapter,
      useFactory: adapterFactory
    }, {
      dateFormatter: {
        provide: CalendarDateFormatter,
        useClass: CustomDateFormatter
      }
    })

这篇关于小时显示小时段角度日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆