typescript 无法绑定到“gridOptions”,因为它不是“ag-grid-angular”的已知属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44238607/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 04:35:33  来源:igfitidea点击:

Cannot bind to 'gridOptions' since it isn't a known property of 'ag-grid-angular'

javascriptangulartypescript

提问by Alon

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

我正在尝试运行ag-grid 的示例项目,但出现以下异常:

Can't bind to 'gridOptions' since it isn't a known property of 'ag-grid-angular'

无法绑定到“gridOptions”,因为它不是“ag-grid-angular”的已知属性

Code:

代码:

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

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.

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

Any help will be profoundly appreciated!

任何帮助将不胜感激!

回答by Suneet Bansal

It seems you have not registered AgGridModule with @NgModule({})

看来您还没有注册 AgGridModule @NgModule({})

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