使用Angular2在ag-grid中找不到按钮点击事件的方法

时间:2016-09-21 03:32:17

标签: angularjs angular typescript ag-grid

我想在 ag-grid 中的按钮点击事件中调用editAsset()方法。

ListComponent:

ngOnInit() {
        this.route.data.forEach((data: { assets: Asset[]}) => {
            this.gridOptions.columnDefs = this.createColumnDefs(data.assets[0]);
            this.gridOptions.rowData = data.assets
        });
  }

private createColumnDefs(asset) {
        let keyNames = Object.keys(asset);
        let headers = []
        keyNames.filter(key => key != '__v' && key != '_id').map(key => {
            headers.push({
                headerName: key,
                field: key,
                width: 100
            })
        });

        headers.push({
            headerName: 'update',
            field: 'update',
            cellRendererFramework: {
                template: '<button (click) = "editAsset()"> Edit </button>'
            },
            width: 100
        });
        return headers;
    }

  editAsset(): void {
    alert("here");
  }

这两个都在同一个组件中定义。

但它无法找到该方法并显示以下错误:

Here's the Snapshot of error report

Here's the grid

0 个答案:

没有答案