When creating components, Angular generates a unique component ID for each component. This is generated using the Angular component metadata, including but not limited: selectors, the number of host bindings, class property names, view and content queries. When two components metadata are identical (often times sharing the same selector), an ID generation collision will occur.
Component IDs are used in Angular internally:
To avoid issues that might be caused by the component ID collision, it's recommended to resolve them as described below.
Example of a Component ID collision
@Component({ selector: 'my-component', template: 'complex-template', }) class SomeComponent {} @Component({ selector: 'my-component', template: 'empty-template', }) class SomeMockedComponent {}
Having these two components defined will trigger an ID generation collision and during development a warning will be displayed.
The warning message includes the class name of the two components whose IDs are colliding.
The problem can be resolved using one of the solutions below:
:not()
and a different tag name. @Component({ selector: 'my-component:not(p)', template: 'empty-template', }) class SomeMockedComponent {}
@Component({ selector: 'my-component', template: 'complex-template', host: {'some-binding': 'some-value'}, }) class SomeComponent {}
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/errors/NG0912