本文介绍了直接使用 mat-datepicker 无需输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将日期选择器放在始终可见且不依赖于输入的永久侧边栏中,这可能吗?我想只要把组件放在里面并添加 opens = true 就可以让 datepicker 在一个盒子里总是可见的.
I want to put the datepicker in a permanent sidebar always visible and not dependent on an input, is this possible?I imagined that just putting the component and adding opened = true could leave the datepicker inside a box always visible.
推荐答案
事实证明这是非常简单的,像往常一样导入 MatDatePickerModule,然后简单地使用 mat-calendar 选择器
turns out this is pretty straightforward import the MatDatePickerModule as per usual and then simply use the mat-calendar selector
<mat-calendar></mat-calendar>
为了通过打字稿挂钩选择
In order to hook into the selection via typescript
@ViewChild(MatCalendar) _datePicker: MatCalendar<Date>
ngOnInit() {
this._datePicker.selectedChange.subscribe(x => {
console.log(x);
});
}
这篇关于直接使用 mat-datepicker 无需输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!