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

后端 未结 9 1895
深忆病人
深忆病人 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:52

    Like @nonstopbutton said, adding autoscroll="true" to my ngView element worked for me too. I mention this here because it was a comment to an answer and it was not easy to see his reply.

    More information here: https://stackoverflow.com/a/24549173/1578861

    0 讨论(0)
  • 2021-02-07 00:53

    In the controller you can actually drop the $ from window and simply putwindow.scrollTo(0,0); without having to inject $window into the controller. It worked great for me.

    0 讨论(0)
  • 2021-02-07 00:54

    I'd a similar issue with Chrome. However, I don't know if any specific external library is causing this issue or otherwise.

    However I wrote this piece of code at app level and it works.

     $rootScope.$on('$viewContentLoaded', function(){
                    $window.scrollTo(0, 0);
                });
    
    0 讨论(0)
提交回复
热议问题