When a component is declared and exported in a shared module, importing that shared module into multiple feature modules allows reuse without redeclaration. Angular does not duplicate the component but shares the same declaration.
MyButtonComponent?A component must be declared in the module's declarations array before it can be exported. Also, importing CommonModule is standard for shared modules to use common directives.
MyCardComponent. You imported the shared module into a feature module but get an error: 'my-card' is not a known element. What is the most likely cause?If a component is declared but not exported in a shared module, importing that module does not make the component available to other modules. Exporting is necessary for reuse.
Providing a service in a shared module creates a new instance for each module that imports it, because each module has its own injector. To share a single instance app-wide, provide the service in the root injector.
Best practice is to separate reusable components into a shared module that exports them, and provide services using providedIn: 'root' to ensure singleton instances. This avoids multiple service instances and keeps modules focused.