Can't figure out why page loads at bottom? Angular UI-Router autoscroll Issue

前端 未结 5 2039
眼角桃花
眼角桃花 2020-12-13 14:18

For the life of me, I cannot figure out why this home page loads at the bottom. Is this an angular ui-router, angular, javascript or CSS issue? I\'ve been stuck on this fo

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 15:13

    here is a possible solution, i used a workoround, since auto scrolling wasnt working for me, so i forced my view to scroll to top. Hope this helps.

    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);
    
    });
    
    
    
    }]);
    

提交回复
热议问题