How to initialize ag-grid api in angular2 application

前端 未结 3 1126
离开以前
离开以前 2021-01-14 19:00

I am working on an application built using angular2 with typescript. I am using ag-grid to display data in grid but not able to find the grid api.

/// 

        
3条回答
  •  [愿得一人]
    2021-01-14 19:38

    In your ts file there is a gridOptions variable declared in class level. var gridOptions; But you are not assigning any value for it. So it's undefined.

    Inside the constructor you are assigning a value for a gridOptions variable which is local to that method.

    However the gridOptions you have bind with grid is the class level variable which is undefined. So you are getting an error. So modify the code like follows.

    constructor(private _heroService: HeroService) {
        ....
        this.gridOptions = {
            enableSorting: true,
            rowData: this.rowData,
            ....
    

提交回复
热议问题