Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 How to scroll to top of window on user interaction [duplicate]

Tags:

angular

so i am having hard time to figure out how to scroll page to top of window upon user interaction (like click on item). In AngularJS i could use $window.scrollTo(0, 0); I am not using Angular2 Router so need something like aformentioned $window

Any help would be appreciated.

like image 266
LithStud Avatar asked Jun 06 '16 12:06

LithStud


1 Answers

You can use the javascript window object or refer to this link if you want to do it purely in angular 2(Angular2 - How to inject window into an angular2 service):


window.scrollTo(0,0);

like image 187
Nikhilesh K V Avatar answered Nov 18 '22 18:11

Nikhilesh K V