search

Home  >  Q&A  >  body text

angular.js - How to solve the problem that the navigation at the bottom of the page does not scroll to the top of the page after using ui-sref to jump to a new page?

How to solve the problem that the navigation at the bottom of the page does not scroll to the top of the page after using ui-sref to jump to a new page?

某草草某草草2853 days ago656

reply all(3)I'll reply

  • 漂亮男人

    漂亮男人2017-05-15 17:15:50

    Hello, I also encountered this problem. My previous page scrolled to the bottom, but when I jumped to the new routing page, it was still at the bottom. How do I start from the top

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-15 17:15:50

    <ui-view autoscroll/>

    reply
    0
  • 为情所困

    为情所困2017-05-15 17:15:50

    app.run(['$window', '$rootScope', '$location' ,'$cookieStore', '$state', 'CacheManager',  '$timeout', function($window, $rootScope, $location, $cookieStore, $state,CacheManager, $timeout){
    
    
    $rootScope.$on('$viewContentLoaded', function(){
    
    var interval = setInterval(function(){
      if (document.readyState == "complete") {
          window.scrollTo(0, 0);
          clearInterval(interval);
      }
    },200);
    
    });
    
    
    
    }]);

    This method can be implemented, but I don’t know if it is good for performance

    reply
    0
  • Cancelreply