Files

32 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

@name Selector Collision
@category runtime
@videoUrl https://www.youtube.com/embed/z_3Z5mOm59I
@shortDescription Multiple components match with the same tagname
@description
Two or more components use the same [element selector](guide/component-overview#specifying-a-components-css-selector). Because there can only be a single component associated with an element, selectors must be unique strings to prevent ambiguity for Angular.
@debugging
2022-03-10 08:48:09 -08:00
Use the element name from the error message to search for places where you're using the same [selector declaration](guide/architecture-components) in your codebase:
2022-03-10 08:48:09 -08:00
<code-example format="typescript" language="typescript">
&commat;Component({
selector: 'YOUR_STRING',
2022-03-10 08:48:09 -08:00
&hellip;
})
2022-03-10 08:48:09 -08:00
</code-example>
Ensure that each component has a unique CSS selector. This will guarantee that Angular renders the component you expect.
2022-03-10 08:48:09 -08:00
If you're having trouble finding multiple components with this selector tag name, check for components from imported component libraries, such as Angular Material. Make sure you're following the [best practices](guide/styleguide#component-selectors) for your selectors to prevent collisions.
<!-- links -->
<!-- external links -->
<!-- end links -->
@reviewed 2022-02-28