简体   繁体   English

连续调用angular2的回调

[英]callbacks calling continuously angular2

Hi there I have this piece of code: 嗨,我有这段代码:

*p-calendar [(ngModel)]="startDate" showTime="showTime" hourFormat="24" showIcon="true" [minDate]="minDate" [Focus]="test()"*

This is Calendar from Primeng I'm using this Callback 'Focus' and it is calling itself continuously even if the element is not in focus. 这是Primeng的日历,我正在使用此回调“焦点”,即使元素不在焦点上,它也会连续不断地调用自身。 This is happening with all the other callbacks in other modules too. 其他模块中的所有其他回调也正在发生这种情况。 Is this is a known behavior or am I doing something wrong here? 这是已知的行为,还是我在这里做错了什么?

In order to catch focus event you need to use [onFocus] and NOT [Focus] . 为了捕获焦点事件,您需要使用[onFocus]和NOT [Focus]
More info : https://www.primefaces.org/primeng/#/calendar 更多信息: https : //www.primefaces.org/primeng/#/calendar

As @Manos Kaparos wrote you should use "onFocus" to catch the event using () instead of []: 正如@Manos Kaparos所写的那样,您应该使用“ onFocus”来使用()而不是[]来捕获事件:

p-calendar [(ngModel)]="startDate" showTime="showTime" hourFormat="24" 
showIcon="true" [minDate]="minDate" (onFocus)="test()"

hope it hepls! 希望它帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM