{ "id": "api/platform-browser/EventManager", "title": "EventManager", "contents": "\n\n
\n
\n
\n \n API > @angular/platform-browser\n
\n \n
\n \n
\n

EventManagerlink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

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

\n\n \n
\n \n \n \n
\n\nclass EventManager {\n constructor(plugins: EventManagerPlugin[], _zone: NgZone)\n addEventListener(element: HTMLElement, eventName: string, handler: Function): Function\n addGlobalEventListener(target: string, eventName: string, handler: Function): Function\n getZone(): NgZone\n}\n\n\n \n \n\n
\n\n\n \n\n \n \n \n\n\n\n\n\n\n

Constructorlink

\n\n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n

Initializes an instance of the event-manager service.

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

Methodslink

\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n addEventListener()\n \n link

\n \n
\n
\n

Registers a handler for a specific element and event.

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

The HTML element to receive event notifications.

\n\n
\n \n eventName\n string\n

The name of the event to listen for.

\n\n
\n \n handler\n Function\n

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

\n\n
\n\n \n
Returns
\n

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

\n\n \n\n\n \n\n \n
\n
\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n addGlobalEventListener()\n \n link

\n \n
\n
\n

Registers a global handler for an event in a target view.

\n\n
\n
\n \n\n addGlobalEventListener(target: string, eventName: string, handler: Function): Function\n\n \n\n
Parameters
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n target\n string\n

A target for global event notifications. One of \"window\", \"document\", or \"body\".

\n\n
\n \n eventName\n string\n

The name of the event to listen for.

\n\n
\n \n handler\n Function\n

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

\n\n
\n\n \n
Returns
\n

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

\n\n \n\n\n \n\n \n
\n
\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n getZone()\n \n link

\n \n
\n
\n

Retrieves the compilation zone in which event listeners are registered.

\n\n
\n
\n \n\n getZone(): NgZone\n\n \n\n
Parameters
\n

There are no parameters.

\n\n \n
Returns
\n

NgZone

\n\n \n\n\n \n\n \n
\n
\n\n \n
\n\n\n\n \n\n\n
\n
\n\n\n" }