How to keep mat-datepicker calender open, even after selecting a date from calendar?

点点圈 提交于 2019-12-04 06:57:59

问题


I want to keep mat-datepicker open in a particular div. I used opened=true property but it gets closed after selecting a date.


回答1:


This should work for you:

Add this to your input

(click)="_openCalendar(picker)"
#keepOpen

This to your mat-datepicker

(closed)="_openCalendar(picker)"

And this to your typescript:

@ViewChild('keepOpen') _input: ElementRef;

_openCalendar(picker: MatDatepicker<Date>) {
  picker.open();
}

Don't forget to import ViewChild and ElementRef

That's my working sample on Stackblitz




回答2:


Use closed event in Datepicker and make it force to open. Working Example: https://stackblitz.com/edit/angular-ysspzm-ge2r2y



来源:https://stackoverflow.com/questions/48589538/how-to-keep-mat-datepicker-calender-open-even-after-selecting-a-date-from-calen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!