角度-是否有HostListener事件列表? [英] Angular - Is there list of HostListener-Events?
问题描述
我在指令中使用hostlistener来检测模糊"事件和"keyup"事件. 现在,我需要检测指令所在的input-element的更改.我尝试过
I am using a hostlistener in a directive to detect "blur"- and "keyup"-events. Now I need to detect changes in the input-element the directive sits on. I tried
@HostListener('change', ['$event'])
但不会触发.
是否存在更改"事件?我还读过,应该有一个输入"事件,但这也不会触发.
Is there a "change"-event? I have also read, that there should be an "input"-event, but that does not fire either.
所以,我的问题是: 有可用的可用事件列表吗?
So, my question is: Is there a list of available events that I can use?
我已经搜索过Google:
I have searched google:
https://www.google.de/search?q = angular + 2 + list + of + hostlistener + events
和角度文档:
https://angular.io/api/core/HostListener
但没有找到任何东西.
推荐答案
Open angular dom element schema https://github.com/angular/angular/blob/master/packages/compiler/src/schema/dom_element_schema_registry.ts#L78
其中:
- (无前缀):属性是一个字符串.
-
*
:属性表示一个事件. -
!
:属性是一个布尔值. -
#
:属性是数字. -
%
:属性是一个对象.
- (no prefix): property is a string.
*
: property represents an event.!
: property is a boolean.#
: property is a number.%
: property is an object.
然后按ctrl+F
并输入*
@HostListener
(还有(customEvent)="handler()"
)也可以收听自定义事件
@HostListener
(and also (customEvent)="handler()"
) can also listen to custom events
Example
这篇关于角度-是否有HostListener事件列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!