I have to use the alert component into different modules A and B in Angular. Even if the implementation is the same for both modules, the tag is recognized as such only in module A. Module B returns in the webbrowser the error:
Uncaught Error: Template parse errors: 'alert' is not a known element:
The project structure is the following:
app
_directives
alert.component.html
alert.component.scss
alert.component.ts
index.ts
app.module.ts
Module B
moduleB.module.ts
.
.
Module A
moduleA.module.ts
.
.
The index.ts file exports the component:
export * from './alert.component';
In Module B (the working module) the component is imported as following: moduleB.module.ts
import { AlertComponent } from 'app/_directives/alert.component';
.
.
@NgModule({
declarations: [
.
.
AlertComponent,
.
.
The exactly same logic is used for module A where I get the error.
Do you have any ideas how to solve this? Thank you!
i will suppose that you know how to create and import modules.
So you need to :
that's it :)