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

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


Angular UI-Router recently updated it's app so that it automatically scrolls down to new views loaded by default. This was causing my app's pages to load scrolled down. To turn this off simply add the following attribute to your ui-view:

<div ui-view="header" autoscroll="true"></div>


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


in the run block add:

$rootScope.$on('$stateChangeSuccess', function () {  $anchorScroll(); });

Of course you have to inject the $anchorScroll dependency