0

i am facing this problem while creating the new project on MDB angular . I have created multiple modules like public , tutor and student . public module is not lazy loaded while others are lazy loaded . public module is working perfect .

import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform- 
browser/animations';
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AgmCoreModule } from '@agm/core';
import { AppComponent } from './Main/app.component';

import { SharedModule } from './shared/shared.module';
import { AppRoutingModule } from './app-routing.module';
import { PublicModule } from './public/public.module';
import { PageNotFoundComponent } from './Main/page-not-found/page-not- 
found.component';
import { ToastModule } from 'ng-uikit-pro-standard';
import { CoreModule } from './core/core.module';

@NgModule({
declarations: [
AppComponent,
PageNotFoundComponent
],
imports: [
PublicModule,
CoreModule,
AppRoutingModule,
BrowserModule,
ToastModule.forRoot(),
BrowserAnimationsModule,
FormsModule,
SharedModule,
AgmCoreModule.forRoot({
  // https://developers.google.com/maps/documentation/javascript/get-api- 
  key?hl=en#key
  apiKey: 'Your_api_key'
})
 ],
 bootstrap: [AppComponent],
schemas:      [ NO_ERRORS_SCHEMA ]
})
export class AppModule { }





import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PageNotFoundComponent } from './Main/page-not-found/page-not- 
found.component';

const routes: Routes = [
{ path: 'tutor', loadChildren: './tutor/tutor.module#TutorModule' },
// { path: 'admin', loadChildren: './admin/admin.module#AdminModule' },
 //  { path: '**', component: PageNotFoundComponent}
 ];

 @NgModule({
imports: [RouterModule.forRoot(routes)],
 exports: [RouterModule]
})
export class AppRoutingModule { }



import { NgModule } from '@angular/core';

import { TutorRoutingModule } from './tutor-routing.module';
import { SharedModule } from '../shared/shared.module';
import { TutorLayoutComponent } from './tutor-layout/tutor- 
layout.component';

@NgModule({
declarations: [TutorLayoutComponent],
imports: [
SharedModule,
TutorRoutingModule
 ]
})
 export class TutorModule { }



import { NgModule } from '@angular/core';
  import { Routes, RouterModule } from '@angular/router';
  import { TutorLayoutComponent } from './tutor-layout/tutor- 
 layout.component';

 const routes: Routes = [
 {path: '', component: TutorLayoutComponent}
];

 @NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
 })
 export class TutorRoutingModule { }

I want to lazy load all modules except my public module.But i don't know why it is showing me the message that Browser Module Is already loaded . i have already tried multiple tries to solve it .

  • if you have imported `import { BrowserAnimationsModule } from '@angular/platform` then there is no need of `import { BrowserModule } from '@angular/platform-browser';` its already included so remove it – Joel Joseph Apr 25 '19 at 07:15
  • also after removing the import of BrowserModule , stop ng serve and run it again – Joel Joseph Apr 25 '19 at 07:16

0 Answers0