Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

common or browser module on lazyload angular

I’m using lazy load, but when opening the child component i’m getting this error

core.js:10144 NG0303: Can't bind to 'ngForOf' since it isn't a known property of 'div'.

I have read many articles, there had said that I’ll add Common Module or Browser Module I have added these modules in the app module but there was no a difference also I have tried to add the modules into system.module but unfortunately there was no difference, where I should add these modules?

App module

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CommonModule } from '@angular/common';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { SystemModule } from './view/system/system.module';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    CommonModule,
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    SystemModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

System Module

import { NgModule } from '@angular/core';
import { SystemRoutingModule } from './system-routing.module';

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { SystemComponent } from './system.component';
import { HomeComponent } from './components/home/home.component';
import { ChatComponent } from './components/chat/chat.component';
@NgModule({
  declarations: [
    SystemComponent,
    HomeComponent,
    ChatComponent
  ],
  imports: [
    NgbModule,
    SystemRoutingModule,
  ],
  exports: [
      HomeComponent,
      ChatComponent
  ],
  providers: [],
})
export class SystemModule { }

>Solution :

The CommonModule needs to be imported into the module where your component is declared.

That means when lazy loading your module, you need to import them.

Adding it to your SystemModule should resolve the issue. If not, please provide a reproductible example showing the issue (you can use Stackblitz to do that).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading