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


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 for two hours and not knowing why my html page loads at the bottom instead of the top is really killing my self-esteem as a programmer :/

Here is the home page: [ URL Redacted ]

UPDATE -- I solved this issue. It was with Angular UI-Router. See my answer below for the simple fix.

I use Angular and Angular UI-Router and the set up looks like this...


  doctype html
  html(lang='en', xmlns='', xmlns:fb='', itemscope='itemscope', itemtype='')
  include ../includes/head
  block content
  include ../includes/foot


extends layouts/default

block content

Angular Config.js$stateProvider, $urlRouterProvider) {
// For any unmatched url, redirect to "/"
// Now set up the states
    .state('home', {
      url: "/",
      views: {
        "header":    { templateUrl: "views/header/home.html"   },
        "content":   { templateUrl: "views/content/home.html"  },
        "footer":    { templateUrl: "views/footer/footer.html" }
      resolve: { factory: setRoot }
    .state('signin', {
      url: "/signin",
      views: {
        "header":    { templateUrl: "views/header/signin.html"   },
        "content":   { templateUrl: "views/content/signin.html"  },
        "footer":    { templateUrl: "views/footer/footer.html" }
      resolve: { factory: setRoot }
Problem courtesy of: ac360


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>
Solution courtesy of: ac360


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.['$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);


Discussion courtesy of: Karan Khanna

in the run block add:

$rootScope.$on('$stateChangeSuccess', function () {

Of course you have to inject the $anchorScroll dependency

Discussion courtesy of: christina

I ran into this issue a while ago. What is happening is you are on page 1, scrolled down the page I imagine, then click a button to go to page 2. The router then doesn't readjust your scroll position when you go to the next page. I fixed this by scrolling to top on all route changes.

Discussion courtesy of: Mindstormy

This recipe can be found in it's original form on Stack Over Flow.