我正在使用Angular Calendar(请参阅这里的演示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;
}
}
}
但我没有使用点击事件。我该怎么做?
您链接到的组件中有一个现场演示,正是您需要做的事情。选择多天并用粉红色着色,完整代码和提到的演示:https://mattlewis92.github.io/angular-calendar/#/selectable-period
有一个预定义的css类.cal-day-selected
用于为所选日期着色,在演示中所选日期在数组selectedDays: any = [];
内