Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Angular throws NG05102: Unsupported event target when a listener uses a string for a global event target that Angular does not recognize. The supported strings are window, document, and body. Correct a typo or unsupported target, or pass the actual DOM element when the listener belongs to a specific element.

What NG05102 means

NG05102 is about the listener’s target, not the event name. Angular cannot resolve an unsupported string as a global target. Its error guidance identifies the accepted strings as window, document, and body; the Component API lists the same global prefixes for host event handling.

Do not confuse this error with NG05101, which concerns an event that has no event manager plugin. NG05102 specifically concerns an unsupported event target.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to fix NG05102

Find the listener registration that triggers the error and check its target. Angular’s error guidance calls out @HostListener and Renderer2.listen() as places to inspect.

Correct a global target in @HostListener

For a global event, put one of the recognized target names before the colon. For example, Angular’s documented typo windw:resize should be window:resize:

@HostListener('window:resize')
onResize() {}

Use document or body instead when that is the intended global target. A value such as global is not a supported target string.

Check the first argument to Renderer2.listen()

If the first argument is a string, use only window, document, or body for a global listener. If the listener should attach to a particular element, pass that DOM element rather than inventing another global-target string. Angular’s example uses the element reference’s native element:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
this.renderer.listen(this.elementRef.nativeElement, 'click', handler);

Which target should you use?

Listener scope What to pass Example
Global event One of the supported strings: window, document, or body. @HostListener('window:resize')
One specific DOM element The actual DOM element, such as an element reference’s nativeElement. this.renderer.listen(this.elementRef.nativeElement, 'click', handler)
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Angular version context

Angular’s error encyclopedia classifies NG05102 as a runtime error. The reviewed documentation does not specify the first Angular release that introduced it, a complete affected-version range, or release-specific behavior, so no version boundary can be stated here. The API reference identifies itself as Angular v22.2.1.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.