Lazy Loading BrowserModule has already been loaded while importing NgClockPickerLibModule in lazy loaded module

366 views Asked by At

Importing NgClockPickerLib Module in Lazy loaded module which is creating error : Error: Uncaught (in promise): Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.

This is because NgClockPickerLib Module internally imports BrowserAnimations Module.

How to use NgClockPickerLib Module in lazy loaded module ??

app module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { SharedDataService } from './services/shared-data.service';


@NgModule({
  declarations: [
    AppComponent,
    ...
  ],
  imports: [
    BrowserModule,  
    AppRoutingModule,
    ...
  ],
  providers: [
    SharedDataService,
    ...
  ],
  exports: [
   
  ],
  bootstrap: [AppComponent]
})

app routing module

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';

const routes: Routes = [
  { path: 'journalling', loadChildren: './Journalling/modules/journalling.module#JournallingModule' }
];

@NgModule({
  imports: [
    CommonModule,
    RouterModule.forRoot(routes)
  ],
  declarations: [

  ],
  exports: [RouterModule]
})
export class AppRoutingModule { }

journalling module

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { JournallingRoutingModule } from './journalling-routing.module';
import { NgClockPickerLibModule } from 'ng-clock-picker-lib';


@NgModule({
  imports: [
    CommonModule,
    JournallingRoutingModule,
    NgClockPickerLibModule
  ],
  declarations: [ 
  ],
  providers: [
  ]
})
export class JournallingModule { }

enter image description here

0

There are 0 answers