AngularJS + Safari: Force page to scroll to top when pages switch

后端 未结 9 2033
深忆病人
深忆病人 2021-02-07 00:20

I am having an odd, safari-only scrolling behavior using AngularJS.

Whenever the user flips between pages, the pages are being changed as if they are AJAX. I understand

9条回答
  •  轮回少年
    2021-02-07 00:33

    Call $window.scrollTo(0,0); after locationChangeSuccess event:

    $rootScope.$on("$locationChangeSuccess",
    function(event, current, previous, rejection) {
      $window.scrollTo(0,0);
    });
    

提交回复
热议问题