我正在使用延遲加載,但是在打開子組件時出現此錯誤
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 { }
uj5u.com熱心網友回復:
需要將 CommonModule 匯入到宣告組件的模塊中。
這意味著在延遲加載模塊時,您需要匯入它們。
將它添加到您的 SystemModule 應該可以解決問題。如果沒有,請提供一個可重現的示例來顯示該問題(您可以使用 Stackblitz 來做到這一點)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/464704.html
上一篇:將列舉元素映射到型別
