【发布时间】:2018-01-06 20:24:34
【问题描述】:
在使用带有 angular4 的 ag-grid 时,我遇到了以下错误消息。
我正在尝试通过 HTTP 获取 json 后显示行数据。
this.gridOptions.api.setRowData(this.gridOptions.rowData);
但我的代码在错误消息下方。
ERROR 错误:未找到 RedComponentComponent 的组件工厂。做过 你把它添加到@NgModule.entryComponents 吗?
这是我的应用模块代码。我已经设置为 entryComponents。
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AgGridModule} from "ag-grid-angular/main";
import { AppComponent } from './app.component';
import { MyGridApplicationComponent } from './my-grid-application/my-grid-application.component';
import { RedComponentComponent } from './red-component/red-component.component';
@NgModule({
imports: [
BrowserModule,
AgGridModule.withComponents(
[RedComponentComponent]
),
FormsModule,
HttpModule
],
declarations: [
AppComponent,
MyGridApplicationComponent,
RedComponentComponent
],
entryComponents: [
RedComponentComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
我的问题。为什么这段代码无法解析这个组件。
【问题讨论】:
-
尝试重启服务器。
-
你能提供一个可运行的repro吗?
-
@Ploppy 重新启动了服务器。但仍然会发生。
-
@yurzui 这是可运行的存储库。 github.com/badsaarow/CommCodeViewer