Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go to Top of page on button click in Angular 2

Tags:

angular

Want to go to top of the page on button click , Currently I using following code which is not working :

HTML:

<button md-raised-button class="md-raised md-primary" (click)="onEdit()">Edit</button>

Function:

onEdit(){
    window.scrollTo(0,0);
  }
like image 478
GsMalhotra Avatar asked Dec 28 '16 13:12

GsMalhotra


Video Answer


1 Answers

onEdit(){
    document.body.scrollTop = document.documentElement.scrollTop = 0;
  }
like image 67
anshuVersatile Avatar answered Nov 15 '22 21:11

anshuVersatile