I have a form where I am adding objects to An array, then I am giving the user a preview of the created objects.
I am looping the array with a *ngFor and each element added to the bottom of the screen. My goal that after each element was added there will be an auto scroll to the bottom of the page
Currently i am using a setTimeOut function, but i was wondering is there a better way?
this.createdAppointments.push(appointmentFormValues);
setTimeout(() => {
window.scrollTo(0, document.body.scrollHeight || document.documentElement.scrollHeight);
}, 1);