Brand new to Ionic/Angular development, I have the following structure
- src
-- /app
---- app.component.ts
---- app.module.ts
---- main.ts
---- ...
-- /pages
---- /event-home
------ /event-home.module.ts
------ /event-home.ts
event-home.module.ts:
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { EventHomePage } from './event-home';
@NgModule({
declarations: [
EventHomePage,
],
imports: [
IonicPageModule.forChild(EventHomePage),
],
entryComponents: [
EventHomePage
]
})
export class EventHomePageModule {}
app.module.ts
import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { EventEntryPage, EventHomePage, EventDiscussionPage,
EventHandoutsPage, EventInfoPage } from "../pages/pages";
@NgModule({
declarations: [
MyApp,
EventEntryPage,
EventHomePage,
EventDiscussionPage,
EventHandoutsPage,
EventInfoPage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
EventEntryPage,
EventHomePage,
EventDiscussionPage,
EventHandoutsPage,
EventInfoPage
],
providers: [
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
I am trying to do a deeplink to http://localhost:8100/#/event-home, which, within event-home.ts I use IonicPage()
.
When I visit the url, I get Error: Type EventHomePage is part of the declarations of 2 modules: AppModule and EventHomePageModule! Please consider moving EventHomePage to a higher module that imports AppModule and EventHomePageModule.
I think I need to be creating a shared module, but I'm still trying to wrap my head around how to do this. I started with something like:
import {NgModule} from "@angular/core";
import {EventHomePage} from "../pages/event-home/event-home";
@NgModule({
declarations: [ EventHomePage ],
exports: [ EventHomePage ]
})
export class SharedModule {}
But I'm stuck at, "what do I do now?". If it isn't clear yet, I am kind of poking around blind here so if I'm chasing the wrong solution, please point that out.