Angular 8 scroll to a fragment, doesn't bring the fragment to the top of the page
I use code like this to scroll to element:
HTML:
<button (click)="scroll(target)"></button>
<div #target>Your target</div>
TS:
scroll(el: HTMLElement) {
el.scrollIntoView();
}
Maybe this helps you.
Remember: to page scroll to element, page must have sufficient contents do generate a scroll/scrollbar, otherwise does not have content to scroll.