更改突出显示日期的背景后如何刷新mat-calendar [英] How to refresh mat-calendar after changing the background of highlighted dates
问题描述
我有一个总是打开的垫日历控件.在初始加载时,我突出显示了可以执行以下操作的日期数组:突出显示日历中的某些日期.现在,我必须在单击按钮时突出显示今天(或选定的日期).仅当我更改为其他月份,然后返回到当前月份的视图时,突出显示才起作用.有没有一种方法可以动态刷新垫日历?请告知.
I have a mat-calendar control which is open always. On initial load, I am highlighting an array of dates which was able to do following this: Highlighting certain dates in mat-calendar. Now I have to highlight today's day (or selected date) on a button click. The highlighting works only when I change to different month, and then come back to the current month's view. Is there a way to refresh the mat-calendar dynamically? Please advise.
https://am-all-imports-zwnjbd.stackblitz.io
推荐答案
您可以简单地使用 MatCalendar.updateTodaysDate()
重新呈现它.
You can simply use MatCalendar.updateTodaysDate()
to re-render it.
@ViewChild(MatCalendar) calendar: MatCalendar<Date>;
someEvent(){
this.calendar.updateTodaysDate();
}
这篇关于更改突出显示日期的背景后如何刷新mat-calendar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!