更改突出显示日期的背景后如何刷新 mat-calendar [英] How to refresh mat-calendar after changing the background of highlighted dates
问题描述
我有一个永远打开的 mat-calendar 控件.在初始加载时,我突出显示了一系列能够执行以下操作的日期:Highlightingmat-calendar 中的某些日期.现在我必须通过单击按钮突出显示今天(或选定的日期).只有当我更改为不同的月份,然后返回到当前月份的视图时,突出显示才有效.有没有办法动态刷新 mat-calendar?请指教.
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屋!