angular - 如何在 Angular 日历包中选择一天

标签 angular angular-calendar

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

而且我需要将不同的类(class)应用到我选择的一天(或更多)。 所以,如果我点击一天(或更多),我需要它们是粉红色或其他颜色。

我用today cell做过类似的事情

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;
          }
     }
}

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

最佳答案

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

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

关于angular - 如何在 Angular 日历包中选择一天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51781445/

相关文章:

用于周 View 的 Angular 6+ 日历自定义事件模板不起作用

angular - 基于最大值和最小值的 Ag 网格单元线性渐变颜色

jquery - 使用 jQuery 和 jQuery UI 运行任何 Jest 测试时出现问题

angular - 如何在 Angular 日历周 View 中使用 ng-template 以不同颜色显示特定时间

javascript - AngularJS angular-ui-calendar TypeError : this. $compile 不是函数; this.$compile 在 $onInit() 内部有值,但在外部未定义

javascript - Angular Material 数据表显示 [object Object]

angular - Typescript 中的私有(private)参数

angular - 如何忽略 Angular 中的子路径?

Angular 日历 subFn 不是函数