mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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.
This commit is contained in:
committed by
Kirill Cherkashin
parent
7fc46ed3a1
commit
dead64fbdb
@@ -0,0 +1,26 @@
|
||||
# No event manager plugin found for event
|
||||
|
||||
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.
|
||||
|
||||
## Debugging the error
|
||||
|
||||
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:
|
||||
|
||||
```html
|
||||
<!-- 'keyup.ente' is not recognized -->
|
||||
<input (keyup.ente)="onEnter()" />
|
||||
|
||||
<!-- Correct -->
|
||||
<input (keyup.enter)="onEnter()" />
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```typescript
|
||||
import {ApplicationConfig} from '@angular/core';
|
||||
import {EVENT_MANAGER_PLUGINS} from '@angular/platform-browser';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [{provide: EVENT_MANAGER_PLUGINS, useClass: MyCustomPlugin, multi: true}],
|
||||
};
|
||||
```
|
||||
@@ -13,7 +13,7 @@ export const enum RuntimeErrorCode {
|
||||
// (undocumented)
|
||||
HYDRATION_CONFLICTING_FEATURES = 5001,
|
||||
// (undocumented)
|
||||
NO_PLUGIN_FOR_EVENT = 5101,
|
||||
NO_PLUGIN_FOR_EVENT = -5101,
|
||||
// (undocumented)
|
||||
ROOT_NODE_NOT_FOUND = -5104,
|
||||
// (undocumented)
|
||||
|
||||
@@ -16,7 +16,7 @@ export const enum RuntimeErrorCode {
|
||||
|
||||
// misc errors (5100-5200 range)
|
||||
BROWSER_MODULE_ALREADY_LOADED = 5100,
|
||||
NO_PLUGIN_FOR_EVENT = 5101,
|
||||
NO_PLUGIN_FOR_EVENT = -5101,
|
||||
UNSUPPORTED_EVENT_TARGET = 5102,
|
||||
TESTABILITY_NOT_FOUND = 5103,
|
||||
ROOT_NODE_NOT_FOUND = -5104,
|
||||
|
||||
@@ -60,7 +60,7 @@ import type {} from 'zone.js';
|
||||
const plugin = new FakeEventManagerPlugin(doc, ['dblclick']);
|
||||
const manager = new EventManager([plugin], new FakeNgZone());
|
||||
expect(() => manager.addEventListener(element, 'click', null!)).toThrowError(
|
||||
'NG05101: No event manager plugin found for event click',
|
||||
'NG05101: No event manager plugin found for event click. Find more at https://next.angular.dev/errors/NG05101',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user