Can anyone explain why this.agGrid is undefined in the ngOnChanges method? It is being set in onGridReady which is executed before the ngOnChanges method.
In my component.ts file
private onGridReady(agGrid) {
this.agGrid = agGrid // set property
console.log(1, this.agGrid)
}
ngOnChanges(changed) {
console.log(2, this.agGrid) // property undefined
}
console output:
1 Object { type: "gridReady", api: {…}, columnApi: {…} }
2 undefined
Any idea why this.agGrid is not defined in ngOnChanges?
Edit (showing how onGridReady is called):
html
<ag-grid-angular
class="ag-theme-balham"
style="width: 100%; height: 100%;"
[gridOptions]="gridOptions">
</ag-grid-angular>
more of the ts file
private createGridOptions() {
const gridOptions = {};
gridOptions['onGridReady'] = this.onGridReady;
return gridOptions;
}
ngOnInit() {
this.gridOptions = this.createGridOptions();
}