Angular Component automatically scrolls to middle when opened as MAT_DIALOG

159 views Asked by At

I have an angular website, where pages can be opened under specific routes, but I also can (by clicking on specific buttons) open these pages as dialog. When I open these pages as dialogs, the dialog automatically starts at the middle/bottom of the page, although I want to start at the top. I have one component for the page, and one component for the page dialog, that opens this page as dialog. The dialog page is opened when the user clicks on a button

I have tried these things, but they did not work: window.scroll(0, 0) on ngOnInit and AfterViewInit this.scroll.nativeElement.scrollTop = 0; on ngOnInit and AfterViewInit I also have this in my app-routing.module.ts: imports: [RouterModule.forRoot(routes, {scrollPositionRestoration: 'enabled'})]

0

There are 0 answers