I have created a component called commonmod.component.ts that I am including in two other modules (abc and def).
abc.module.ts
import { commonmod } from '../commonmod/commonmod.component';
@NgModule({
declarations: [
commonmod
]
})
def.module.ts
import { commonmod } from '../commonmod/commonmod.component';
@NgModule({
declarations: [
commonmod
]
})
When I redirect one page in abc module to another page in def module, it is throwing me following error.
ERROR Error: Uncaught (in promise): Error: Type commonmod is part of the declarations of 2 modules: abcand def! Please consider moving commonmod to a higher module that imports abc and def. You can also create a new NgModule that exports and includes commonmodthen import that NgModule in abcand def. Error: Type commonmod is part of the declarations of 2 modules: abc and def! Please consider moving commonmodto a higher module that imports abcand def. You can also create a new NgModule that exports and includes commonmod then import that NgModule in abc and def.
commonmod
component in your module ? if yes then you don't have to addcommonmod
to yourdeclartions[]
of other modules. – CruelEnginedeclarations[]
) to as that component has been declared in its module but you have to import that module and add it tiimports[]
– CruelEngineSalaryComponent
toexports[]
inside@NgModule({})
and then add the employer module toimports[]
of the other module where you want to use theSalaryComponent
– CruelEngine