【发布时间】:2018-11-14 01:38:09
【问题描述】:
我在 HTML 中有这段代码:
<ag-grid-angular [gridOptions]="gridOptions"></ag-grid-angular>
组件中的代码:
import {GridOptions} from 'ag-grid';
...
export class SampleComponent{
gridOptions: GridOptions;
}
...
app.module.ts:
import {NgModule} from "@angular/core";
import {AgGridModule} from "ag-grid-angular/main";
import {AppComponent} from "./app.component";
...
@NgModule({
declarations: [...],
imports: [
...
AgGridModule.withComponents([])
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
我得到的错误的根源是什么? 这是完整的错误:
错误:未捕获(承诺中):错误:模板解析错误:无法绑定 到“gridOptions”,因为它不是“ag-grid-angular”的已知属性。
- 如果“ag-grid-angular”是一个 Angular 组件并且它具有“gridOptions”输入,则验证它是该模块的一部分。
- 如果“ag-grid-angular”是一个 Web 组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到该组件的“@NgModule.schemas”中 禁止显示此消息。
【问题讨论】:
-
你能发布你的 app.module.ts
-
@Sanoj_V 解决方案是该问题不能解决我的问题。我已经在导入中有
AgGridModule.withComponents([])。 -
@Sajeetharan 是的,我已经添加了 app.module.ts
-
我不知道这是否会有所帮助,但在我使用
ag-grid的班级中,我有以下导入:import { AgGridNg2 } from 'ag-grid-angular';(我没有AgGridModule的导入)。
标签: angular typescript ag-grid