[英]common or browser module on lazyload angular
我正在使用延遲加載,但是在打開子組件時出現此錯誤
core.js:10144 NG0303: Can't bind to 'ngForOf' since it isn't a known property of 'div'.
我讀過很多文章,有人說我會添加Common Module
或Browser Module
我已經在app module
但沒有什么區別我也嘗試將模塊添加到system.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 { }
系統模塊
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 { }
CommonModule 需要導入到聲明組件的模塊中。
這意味着當延遲加載你的模塊時,你需要導入它們。
將它添加到您的 SystemModule 應該可以解決問題。 如果不是,請提供一個可重現的示例來說明問題(您可以使用 Stackblitz 來做到這一點)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.