I am creating a application in which i am using the Ag-Grid api for listing my database content on the web page. Ag-grid have a predefined api to get the selected row content.
1) Use bind
method to retain context this
this.gridOptions.onSelectionChanged = this.onSelectionChanged.bind(this);
2) You can also use Instance Function
private onSelectionChanged = () => {
console.log(this.gridOptions);
}
3) or inline arrow function
this.gridOptions.onSelectionChanged = () => this.onSelectionChanged();