Ionic creates multiple instances of component class


#1

Ionic v-3.18.0

I have a component “SetPoi” which I want to reuse on two different pages “MapPage” and “MapHazardPage”.
The problem is that ionic creates two different instances of the component SetPoi.
Allthough this topic has been already covered in this forum I couldn’t find a solution to this problem.

To clarify this:
It doesn’t occur with providers. It only happens with components which I use in templates on different pages.

The file system structure looks like this:
components
set-poi (*.html, *.module.ts, *.ts)

pages
map-page (*.html, *.module.ts, .ts)
map-hazard-page (
.html, *.module.ts, *.ts)

app.module.ts:

@NgModule({
declarations: [
MyApp,
SetPoiComponent,…
],
imports: [
BrowserModule,
HttpModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
SetPoiComponent,…
],
providers: [
AppConfig,
AppData,
SetPoiComponent,…
{provide: ErrorHandler, useClass: IonicErrorHandler},
UserProvider,
BackendProvider
]
})
export class AppModule {}