【问题标题】:How to select a day in Angular Calendar package如何在 Angular 日历包中选择一天
【发布时间】:2018-08-10 07:41:03
【问题描述】:

我正在使用 Angular 日历(在此处查看演示 https://mattlewis92.github.io/angular-calendar/#/kitchen-sink

我需要在我选择的一天(或更多天)申请不同的课程。 所以,如果我点击一天(或更多),我需要它们是粉红色的。

我对今天的细胞做了类似的事情

const today_cell: 'today-cell' = 'today-cell';

export class MonthCalendarComponent implements OnInit {

  todayCssClass: string = today_cell;

 beforeMonthViewRender({ body }: { body: CalendarMonthViewDay[] }): void {
       body.forEach(day => {
         if (day.isToday === true) {
            day.cssClass = this.todayCssClass;
          }
     }
}

但我没有使用点击事件。我该怎么做?

【问题讨论】:

  • 您是想选择日期,还是只在您点击一次的每一天应用不同的格式,之后不再对那些日子做任何事情?
  • 选择了几天后,我会将它们发送到数据库,所以我需要保存它们

标签: angular angular-calendar


【解决方案1】:

您链接到的组件中有一个现场演示,可以完全按照您的需要进行操作。选择多天并将它们涂成粉红色,使用完整的代码和如前所述的演示: https://mattlewis92.github.io/angular-calendar/#/selectable-period

有一个预定义的 css 类 .cal-day-selected 用于为所选日期着色,在演示中,所选日期位于数组 selectedDays: any = [];

【讨论】:

  • 我需要在日历中显示星期名称,例如星期一 = mo,星期二 = Tu。请给出一些想法如何做到这一点。
猜你喜欢
  • 2018-05-19
  • 2021-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-25
  • 2021-12-31
  • 1970-01-01
相关资源
最近更新 更多