Skip to content

Commit 4457dfd

Browse files
committed
feat(component): add new feature post-details to always start at the very top.
1 parent 5e0a62f commit 4457dfd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

angular-primeng-app/src/app/components/post-details/post-details.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ButtonModule } from "primeng/button";
1717
import { InputSwitchModule } from "primeng/inputswitch";
1818
import { SanitizerHtmlPipe } from "../../pipes/sanitizer-html.pipe";
1919
import { YoutubeVideoEmbedDirective } from "../../directives/youtube-video-embed.directive";
20+
import { ViewportScroller } from "@angular/common";
2021

2122
@Component({
2223
selector: "app-post-details",
@@ -52,10 +53,12 @@ export class PostDetailsComponent implements OnInit, OnDestroy {
5253
themeService: ThemeService = inject(ThemeService);
5354
private blogService: BlogService = inject(BlogService);
5455
private querySubscription?: Subscription;
56+
private readonly scroller = inject(ViewportScroller);
5557

5658
@Input({ required: true }) postSlug!: string;
5759

5860
ngOnInit(): void {
61+
this.scroller.scrollToPosition([0, 0]);
5962
this.blogURL = this.blogService.getBlogURL();
6063
this.querySubscription = this.blogService
6164
.getBlogInfo(this.blogURL)

0 commit comments

Comments
 (0)