I am trying to use ngZone to update my pagination state once the zone is stable so that the component I am trying to paginate will be fully rendered, and I will get the correct scrollWidth from the renderer.
The way it is being used in Angular Material 2 code is this:
// Update the position once the zone is stable so that the overlay will be fully rendered
// before attempting to position it, as the position may depend on the size of the rendered
// content.
this._ngZone.onStable.asObservable().pipe(first()).subscribe(() => {
this.updatePosition();
});
I do the same in my component and run my own method instead of 'this.updatePosition()'. This doesn't help me to get the latest rendered state though, it still runs too early.
What am I missing here? What is the correct way to use ngZone with onStable?