无需输入即可直接使用mat-datepicker [英] use mat-datepicker directly without input

查看:111
本文介绍了无需输入即可直接使用mat-datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将datepicker放置在始终可见的永久性边栏中,并且不依赖于输入,这可能吗? 我想象过,仅将组件放入并添加open = true可能会使日期选择器始终位于框内.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆