我正在使用 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/