On this page
EventManager
class
final
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
addGlobalEventListener(target: string, eventName: string, handler: Function): Function
getZone(): NgZone
}
Constructor
Initializes an instance of the event-manager service. |
||||||
|
plugins |
EventManagerPlugin[] |
|
_zone |
NgZone |
Methods
addEventListener()
|
|||||||||
---|---|---|---|---|---|---|---|---|---|
Registers a handler for a specific element and event. |
|||||||||
|
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.
addGlobalEventListener()
|
|||||||||
---|---|---|---|---|---|---|---|---|---|
Registers a global handler for an event in a target view. |
|||||||||
|
target |
string |
A target for global event notifications. One of "window", "document", or "body". |
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.
getZone()
|
---|
Retrieves the compilation zone in which event listeners are registered. |
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v14.angular.io/api/platform-browser/EventManager