简体   繁体   English

如何使用@HostListener的捕获阶段

[英]How to use Captured phase of @HostListener

I want to use captured phase of @HostListener. 我想使用@HostListener的捕获阶段。

@HostListener('document:keydown.escape', ['$event']) onKeydownHandler(event: KeyboardEvent) {
    console.log("key pressed");
  }

Above code use default(bubble phase). 上面的代码使用默认(气泡阶段)。 One of the case I want to use captured phase, please help me, how to use captured phase of @HostListener. 我想使用捕获阶段的一种情况,请帮助我,如何使用@HostListener的捕获阶段。

You might have red it already, but this article have a bit about capturing with an example that might be of use: 您可能已经将其标记为红色,但是本文通过一个可能有用的示例介绍了捕获方法:

https://javascript.info/bubbling-and-capturing https://javascript.info/bubbling-and-capturing

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

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