I have some buttons in my Angular 8 app, which have to send the user to the previous page on click. Everything works fine; however, the page is not being scrolled to the top when navigating back. What can I add or edit to make this happen?
import { Location } from '@angular/common';
...
private _location: Location
...
public goBack(): void {
this._location.back();
}
You can use the angular routing concept to route to a different component on click.
Angular routing concept link: https://angular.io/start/start-routing
I hope it works:) If not share your code I'll look into it to help you out.
You can you use scrollPositionRestoration: enabled
in your router module.
Please refer this - https://angular.io/api/router/ExtraOptions#scrollPositionRestoration
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.