Component is part of the declaration of 2 modules

前端 未结 16 737
我在风中等你
我在风中等你 2020-12-04 06:44

I try to build an ionic 2 app. When I try the app in the browser with ionic serve or launch it on an emulator everything works fine.

But when I try to build it every

16条回答
  •  隐瞒了意图╮
    2020-12-04 07:32

    Remove the declaration from AppModule, but update the AppModule configuration to import your AddEventModule.

    .....
    import { AddEventModule } from './add-event.module';  // <-- don't forget to import the AddEventModule class
    
    @NgModule({
      declarations: [
        MyApp,
        HomePage,
        Login,
        Register,
        //AddEvent,  <--- remove this
        EventDetails
    
      ],
      imports: [
        BrowserModule,
        IonicModule.forRoot(MyApp),
        HttpModule,
        AngularFireModule.initializeApp(config),
        AddEventModule,  // <--- add this import here
      ],
      bootstrap: [IonicApp],
      entryComponents: [
        MyApp,
        HomePage,
        Login,
        Register,
        AddEvent,
        EventDetails
      ],
      providers: [
        StatusBar,
        SplashScreen,
        {provide: ErrorHandler, useClass: IonicErrorHandler}, Eventdata, AuthProvider
      ]
    })
    export class AppModule {}
    

    Also,

    Note that it's important that your AddEventModule exports the AddEvent component if you want to use it outside that module. Luckily, you already have that configured, but if it was omitted, you would've gotten an error if you tried to use the AddEvent component in another component of your AppModule

提交回复
热议问题