Angular 控制台角度9警告:Can';t绑定到';ngForOf';因为它不是';t'的已知属性;李';

Angular 控制台角度9警告:Can';t绑定到';ngForOf';因为它不是';t'的已知属性;李';,angular,typescript,ngfor,Angular,Typescript,Ngfor,我使用的是*ngFor数组,它不显示数据。我在app.module.ts中导入了BrowserModule,在我的子模块中导入了CommonModule Chrome控制台显示此警告:无法绑定到“ngForOf”,因为它不是“li”的已知属性 我的代码: .ts app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; im

我使用的是*ngFor数组,它不显示数据。我在app.module.ts中导入了BrowserModule,在我的子模块中导入了CommonModule

Chrome控制台显示此警告:无法绑定到“ngForOf”,因为它不是“li”的已知属性

我的代码:

.ts

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { ViewsModule } from './views/views.module';
import { HttpClientModule } from '@angular/common/http';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    ViewsModule,
    HttpClientModule ,

  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

products属性可能看起来没有信息,但在模板中执行以下操作会显示[Object Object]、[Object Object]

{{products}}

您如何从应用程序模块/组件中引用子模块和子组件

您可能需要从CocoWorkbenchProductModule导出CocoWorkbenchProductListComponent,并在AppModule中导入CocoWorkbenchProductModule

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CocoWorkbenchProductListComponent } from './coco-workbench-product-list/coco-workbench-product-list.component';



@NgModule({
  declarations: [CocoWorkbenchProductListComponent],
  imports: [
    CommonModule
  ]
})
export class CocoWorkbenchProductModule { }

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { ViewsModule } from './views/views.module';
import { HttpClientModule } from '@angular/common/http';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    ViewsModule,
    HttpClientModule ,

  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

{{products}}