Skip to content

Commit f598dcf

Browse files
arturovtkirjs
authored andcommitted
docs: add error guide for NG05101
Adds a new error reference page for NG05101 (NO_PLUGIN_FOR_EVENT), which is thrown when no registered EventManagerPlugin supports the event name passed to addEventListener. The page covers the two common causes: a typo in the event binding and a missing plugin provider. (cherry picked from commit dead64f)
1 parent 5979217 commit f598dcf

4 files changed

Lines changed: 29 additions & 3 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# No event manager plugin found for event
2+
3+
This error occurs when Angular tries to set up a listener for an event but none of the registered event manager plugins recognizes the event name.
4+
5+
## Debugging the error
6+
7+
The error message includes the unrecognized event name, which is usually enough to spot the problem. The most common cause is a typo in the event binding:
8+
9+
```html
10+
<!-- 'keyup.ente' is not recognized -->
11+
<input (keyup.ente)="onEnter()" />
12+
13+
<!-- Correct -->
14+
<input (keyup.enter)="onEnter()" />
15+
```
16+
17+
If the event name is intentional and belongs to a third-party plugin (for example, a Hammer.js gesture event), make sure the plugin is provided via the `EVENT_MANAGER_PLUGINS` token:
18+
19+
```typescript
20+
import {ApplicationConfig} from '@angular/core';
21+
import {EVENT_MANAGER_PLUGINS} from '@angular/platform-browser';
22+
23+
export const appConfig: ApplicationConfig = {
24+
providers: [{provide: EVENT_MANAGER_PLUGINS, useClass: MyCustomPlugin, multi: true}],
25+
};
26+
```

goldens/public-api/platform-browser/errors.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const enum RuntimeErrorCode {
1313
// (undocumented)
1414
HYDRATION_CONFLICTING_FEATURES = 5001,
1515
// (undocumented)
16-
NO_PLUGIN_FOR_EVENT = 5101,
16+
NO_PLUGIN_FOR_EVENT = -5101,
1717
// (undocumented)
1818
ROOT_NODE_NOT_FOUND = -5104,
1919
// (undocumented)

packages/platform-browser/src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const enum RuntimeErrorCode {
1616

1717
// misc errors (5100-5200 range)
1818
BROWSER_MODULE_ALREADY_LOADED = 5100,
19-
NO_PLUGIN_FOR_EVENT = 5101,
19+
NO_PLUGIN_FOR_EVENT = -5101,
2020
UNSUPPORTED_EVENT_TARGET = 5102,
2121
TESTABILITY_NOT_FOUND = 5103,
2222
ROOT_NODE_NOT_FOUND = -5104,

packages/platform-browser/test/dom/events/event_manager_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import type {} from 'zone.js';
6060
const plugin = new FakeEventManagerPlugin(doc, ['dblclick']);
6161
const manager = new EventManager([plugin], new FakeNgZone());
6262
expect(() => manager.addEventListener(element, 'click', null!)).toThrowError(
63-
'NG05101: No event manager plugin found for event click',
63+
'NG05101: No event manager plugin found for event click. Find more at https://next.angular.dev/errors/NG05101',
6464
);
6565
});
6666

0 commit comments

Comments
 (0)