Hi,
I have a component MyComponent and I’d like to use it into two pages ManagerHomePage and CustomerHomePageModule.
I’m using the component in this way:
@Component({
selector: 'app-customer-home',
templateUrl: './customer-home.page.html',
styleUrls: ['./customer-home.page.scss'],
})
export class CustomerHomePage implements OnInit {
@ViewChild(MyComponent) map: MyComponent;
private deviceId: number;
public rentedVehicleId: number = null;
public testWSEnabled = false;
private coordinates;
....
@Component({
selector: 'app-customer-home',
templateUrl: './customer-home.page.html',
styleUrls: ['./customer-home.page.scss'],
})
export class ManagerHomePageModule implements OnInit {
@ViewChild(MyComponent) map: MyComponent;
private deviceId: number;
public rentedVehicleId: number = null;
public testWSEnabled = false;
private coordinates;
....
But in this way I have the error:
core.js:15724 ERROR Error: Uncaught (in promise): Error: Type MyComponent is part of the declarations of 2 modules: ManagerHomePageModule and CustomerHomePageModule! Please consider moving MyComponent to a higher module that imports ManagerHomePageModule and CustomerHomePageModule. You can also create a new NgModule that exports and includes MyComponent then import that NgModule in ManagerHomePageModule and CustomerHomePageModule.
Error: Type MyComponent is part of the declarations of 2 modules: ManagerHomePageModule and CustomerHomePageModule! Please consider moving MyComponent to a higher module that imports ManagerHomePageModule and CustomerHomePageModule. You can also create a new NgModule that exports and includes MyComponent then import that NgModule in ManagerHomePageModule and CustomerHomePageModule.
It says I have to create another module, but it seems like a complicated way to solve the problem.
Are there other simpler ways to solve this problem?
Why I can’t use the same component into two different pages?
Thank you
cld