填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

ng.getListeners

检索与 DOM 元素关联的事件监听器的列表。该列表包含宿主监听器,但不包含在 Angular 上下文之外定义的事件监听器(例如,通过 addEventListener )。

Retrieves a list of event listeners associated with a DOM element. The list does include host listeners, but it does not include event listeners defined outside of the Angular context (e.g. through addEventListener).

      
      ng.getListeners(element: Element): Listener[]
    
参数
element Element

要为其检索 DOM 监听器的元素。

Element for which the DOM listeners should be retrieved.

返回值

DOM 元素上的事件监听器数组。

Listener[]: Array of event listeners on the DOM element.

使用说明

给定以下 DOM 结构:

Given the following DOM structure:

      
      <my-app>
  <div (click)="doSomething()"></div>
</my-app>
    

<div> 上调用 getListeners 将返回一个如下所示的对象:

Calling getListeners on <div> will return an object that looks as follows:

      
      {
  name: 'click',
  element: <div>,
  callback: () => doSomething(),
  useCapture: false
}