本文介绍了无法绑定到'gridOptions',因为它不是'ag-grid-angular'的已知属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行但得到以下异常:

I'm trying to run the example project of ag-grid but getting the following exception:

代码:

<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的官方网站。

It says that there isn't such a prop as 'gridOptions' on ag-grid-angular. It's weird since it comes from the official website of ag-grid.

任何帮助都将深表赞赏!

Any help will be profoundly appreciated!

推荐答案

看来你没有用 @NgModule({})注册AgGridModule

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

Please try below code if missed:

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

这篇关于无法绑定到'gridOptions',因为它不是'ag-grid-angular'的已知属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 17:00