Consider using afterNextRender:
afterNextRender( () => { this.foo(); }, { injector: this.injector } );
"Register callbacks to be invoked the next time the application finishes rendering..." https://angular.dev/api/core/afterNextRender