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
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 { }
CodePudding user response:
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).