Could someone clarify the reason why this.agGrid is showing as undefined in the ngOnChanges method? Despite being set in onGridReady, which runs before the ngOnChanges method.
Within my component.ts file:
private onGridReady(agGrid) {
this.agGrid = agGrid;
console.log(1, this.agGrid);
}
ngOnChanges(changed) {
console.log(2, this.agGrid);
}
console output:
1 Object { type: "gridReady", api: {…}, columnApi: {…} }
2 undefined
Any thoughts on why this.agGrid is not defined in ngOnChanges?
Edit (demonstrating how onGridReady is called):
html
<ag-grid-angular
class="ag-theme-balham"
style="width: 100%; height: 100%;"
[gridOptions]="gridOptions">
</ag-grid-angular>
more from the ts file
private createGridOptions() {
const gridOptions = {};
gridOptions['onGridReady'] = this.onGridReady;
return gridOptions;
}
ngOnInit() {
this.gridOptions = this.createGridOptions();
}