我正在尝试运行the example project of ag-grid,但遇到以下异常:
无法绑定到'gridOptions',因为它不是已知的属性 'AG-网格角'
代码:
<div style="width: 200px;">
<ag-grid-angular #agGrid style="width: 100%; height: 200px;" class="ag-fresh"
[gridOptions]="gridOptions">
</ag-grid-angular>
</div>
它说ag-grid-angular上没有'gridOptions'这样的道具。这很奇怪,因为它来自ag-grid的官方网站。
任何帮助都将深表感谢!
答案 0 :(得分:7)
您似乎没有使用@NgModule({})
如果错过了,请尝试以下代码:
import {NgModule} from "@angular/core";
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({
declarations: [
AppComponent,
MyGridApplicationComponent,
RedComponentComponent
],
imports: [
BrowserModule,
AgGridModule.withComponents(
[RedComponentComponent]
)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}