Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 以编程方式打开启动日历_Angular_Primeng_Primeng Calendar - Fatal编程技术网

Angular 以编程方式打开启动日历

Angular 以编程方式打开启动日历,angular,primeng,primeng-calendar,Angular,Primeng,Primeng Calendar,我使用的是带角度4的Priming组件,但我遇到了一个问题,那就是单击按钮时如何显示日历 看 @组件({ 选择器:“我的应用程序”, 模板:` 你好{{name} `, }) 导出类应用程序{ 名称:字符串; 值:日期; @ViewChild('日历') 日历:任何; 构造函数(){ this.name=`Angular!v${VERSION.full}` } openCalendar(事件:任意){ console.log(事件); } } 我已尝试使用@ViewChild('calend

我使用的是带角度4的Priming组件,但我遇到了一个问题,那就是单击按钮时如何显示日历

@组件({
选择器:“我的应用程序”,
模板:`
你好{{name}


`, }) 导出类应用程序{ 名称:字符串; 值:日期; @ViewChild('日历') 日历:任何; 构造函数(){ this.name=`Angular!v${VERSION.full}` } openCalendar(事件:任意){ console.log(事件); } }
我已尝试使用
@ViewChild('calendar')
获取模板元素引用。我还尝试过使用
@ViewChild('calendar#inputfield')
应用焦点,但这不起作用


您知道如何单击按钮以编程方式打开日历吗?

您可以在启动日历时使用
showOverlay
方法

openCalendar(event: any) {
  this.calendar.showOverlay(this.calendar.inputfieldViewChild.nativeElement);
  event.stopPropagation();
}

如果我对停止传播进行注释,为什么日历不显示?因为单击事件正在冒泡,并且日历已订阅,代码中的日历链接到按钮的位置?因为我也有同样的问题,但是里面有一个标签calendar@DanyY日历HTML元素通过
@ViewChild(…)
注释和HTML中给出的相应名称(
#calendar
)链接到代码。该按钮调用
openCalendar(event:any)
函数,该函数可通过ViewChild(
this.calendar
)访问日历。
openCalendar(event: any) {
  this.calendar.showOverlay(this.calendar.inputfieldViewChild.nativeElement);
  event.stopPropagation();
}