I have this code in HTML:
<ag-grid-angular [gridOptions]="gridOptions"></ag-grid-angular>
code in Component:
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 {
}
What can be the source for the error that I get? Here is the full error:
Error: Uncaught (in promise): Error: Template parse errors: Can't bind to 'gridOptions' since it isn't a known property of 'ag-grid-angular'.
- If 'ag-grid-angular' is an Angular component and it has 'gridOptions' input, then verify that it is part of this module.
- If 'ag-grid-angular' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
答案 0 :(得分:0)
Try to initiatlize gridOptions as follows and see
constructor() {
this.gridOptions = <GridOptions>{};
this.columnDefinitions = [
];
this.gridOptions = {
columnDefs: this.columnDefinitions,
enableFilter: true,
enableSorting: true,
pagination: true
};
this.rowSelection = 'single';
}
EDIT
Your actual issue is here, Change
From
<ag-grid-angular [gridOptions]="gridOptions"></ag-grig-angular>
To
<ag-grid-angular [gridOptions]="gridOptions"></ag-grid-angular>
答案 1 :(得分:0)
您也可以在cae中创建不包含gridOptions的网格。请在下面找到完整的代码:-
<ag-grid-angular style="width: 500px;height: 200px;" class="ag-theme-balham" [animateRows]="true" [columnDefs]="columnDefs" [enableSorting]="true" [enableFilter]="true" (gridReady)="OnGridReady($event)">