Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

EventManager

An injectable service that provides event management for Angular through a browser plug-in.

      
      class EventManager {
  constructor(plugins: EventManagerPlugin[], _zone: NgZone)
addEventListener(element: HTMLElement, eventName: string, handler: Function): Function
getZone(): NgZone }

Constructor

Initializes an instance of the event-manager service.

This class is "final" and should not be extended. See the public API notes.

      
      constructor(plugins: EventManagerPlugin[], _zone: NgZone)
    
Parameters
plugins EventManagerPlugin[]
_zone NgZone

Methods

Registers a handler for a specific element and event.

      
      addEventListener(element: HTMLElement, eventName: string, handler: Function): Function
    
Parameters
element HTMLElement

The HTML element to receive event notifications.

eventName string

The name of the event to listen for.

handler Function

A function to call when the notification occurs. Receives the event object as an argument.

Returns

Function: A callback function that can be used to remove the handler.

Retrieves the compilation zone in which event listeners are registered.

      
      getZone(): NgZone
    
Parameters

There are no parameters.

Returns

NgZone