【问题标题】:Cannot bind to 'gridOptions' since it isn't a known property of 'ag-grid-angular'无法绑定到“gridOptions”,因为它不是“ag-grid-angular”的已知属性
【发布时间】:2017-10-29 12:48:24
【问题描述】:

我正在尝试运行 the example project of ag-grid,但出现以下异常:

无法绑定到“gridOptions”,因为它不是 'ag-grid-angular'

代码:

<div style="width: 200px;">
  <ag-grid-angular #agGrid style="width: 100%; height: 200px;" 
    [gridOptions]="gridOptions" class="ag-fresh">
  </ag-grid-angular>
</div>

它说在 ag-grid-angular 上没有像“gridOptions”这样的道具。奇怪,来自ag-grid官网。

任何帮助将不胜感激!

【问题讨论】:

    标签: javascript angular typescript ag-grid-angular


    【解决方案1】:

    你好像没有在@NgModule({})注册AgGridModule

    如果错过请尝试以下代码:

    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 {
    }
    

    【讨论】:

    • 别忘了重启你的应用服务器
    猜你喜欢
    • 2018-11-14
    • 2022-01-27
    • 2020-09-24
    • 2021-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-04
    • 2020-09-10
    相关资源
    最近更新 更多