Problem with module declarations


#1

Hello!
I have this error when i try to lauch my app in lab. Having trouble with LoginPage. Can anyone help with this problem?

Here is my files:



#2

Just as the error says, don’t import the page into two separate modules. Import into app.module.ts if you want to eagerly load, and import into the dedicated page module with IonicPage if you want to lazily load.


#3

Take some time and grok: https://angular.io/guide/styleguide

For example: https://angular.io/guide/styleguide#core-feature-module

Keep the entries in your AppModule to a minimum:

@NgModule({
  declarations: [ AppComponent ],
  imports: [
    BrowserModule,
    CoreModule,
    IonicModule.forRoot(AppComponent, {
      backButtonText: ''
    })
  ],
  bootstrap: [ IonicApp ],
  entryComponents: [ AppComponent ]
})
export class AppModule {}

Do the heavy lifting in your CoreModule (e.g., your singleton services):

@NgModule({
  imports: [
    CommonModule,
    IonicModule,
    AngularFireModule.initializeApp(ENV.firebase),
    AngularFirestoreModule,
    AngularFireAuthModule,

    ...

    ENV.production ? ServiceWorkerModule.register('/ngsw-worker.js') : []
  ],
  exports: [],
  declarations: [],
  providers: [
    AuthService,
    { provide: ErrorHandler, useClass: IonicErrorHandler },
    GeolocationService,

    ...

    { provide: LoggerService, useClass: ConsoleLoggerService },
    MapsApiLoaderService
  ]
})
export class CoreModule {
  constructor( private afs: AngularFirestore,
               @Optional() @SkipSelf() parentModule: CoreModule) {

    throwIfAlreadyLoaded(parentModule, 'CoreModule');

    const settings = { timestampsInSnapshots: true };
    afs.app.firestore().settings(settings);
  }
}

Build Error "Type .... is part of the declarations of 2 modules: AppModule