Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk2 min

Angular NG8111: How to Fix Uninvoked Functions in Event Bindings

Angular NG8111 flags an event binding that refers to a function without invoking it. Add parentheses to call the handler, and pass $event only when needed.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

NG8111 means an Angular event binding refers to a function without calling it. Change a binding such as (click)="onClick" to (click)="onClick()" so Angular invokes the handler when the event occurs. If the handler needs the event details, pass $event, for example (keyup)="updateField($event)".

What NG8111 means

Angular’s NG8111 diagnostic reference describes this warning as detecting uninvoked functions in event bindings. In an event expression, writing a function’s name alone refers to the function; it does not call it. As a result, the handler does not run when the event fires.

As an Amazon Associate I earn from qualifying purchases.

For example, the first button below contains a function reference, while the second contains a function call:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<!-- Function reference: triggers NG8111 -->
<button (click)="onClick">Click me</button>

<!-- Function call: invokes the handler on click -->
<button (click)="onClick()">Click me</button>

How to fix the binding

  1. Find the event binding named in the NG8111 warning, such as (click), (keyup), or (keydown).

  2. Check whether its expression names a function without parentheses. If so, add the call parentheses: (click)="onClick()".

  3. If the handler needs information about the event, pass Angular’s $event variable: (keyup)="updateField($event)". Angular’s event-listener guide documents both handler calls and access to $event.

Use the arguments the handler actually needs; adding $event is not required when the handler does not use event details.

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

Where event bindings can appear

In a component template

Parentheses around an event name define an event listener, and the value is the statement Angular evaluates when the event occurs. Besides events such as click, keydown, and keyup, Angular supports key modifiers such as (keydown.enter) and (keydown.shift.enter), as well as global targets such as (window:keydown). The same invocation rule applies: write a function call when the event should invoke that function.

On a component host

Host event bindings behave like event bindings in a component template. Angular’s host-elements guide recommends the component’s host property rather than @HostBinding and @HostListener, which it identifies as existing for backwards compatibility. Wherever the event binding is declared, ensure its expression calls the intended handler.

When Angular reports NG8111

NG8111 is an extended diagnostic. Angular requires strictTemplates to be enabled for extended diagnostics to be emitted; this specific check has no additional requirement. If the diagnostic is absent, its absence alone does not establish that the binding invokes the handler correctly.

You can suppress the check in angularCompilerOptions.extendedDiagnostics.checks by setting uninvokedFunctionInEventBinding to "suppress". Suppression hides the warning; it does not change the binding or make an uninvoked function run. For an event handler intended to execute, calling the function is the correction.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A separate event-binding behavior to know

NG8111 concerns whether a function is invoked. Separately, Angular’s Component API reference notes that an event-binding value is a statement and that if the statement evaluates to false, Angular applies preventDefault() to the DOM event. This behavior is distinct from the missing-call issue diagnosed by NG8111.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.