$anchorScroll

$anchorScroll

by saidulu401

HTML

<div ng-app="MY_APP" >
<div id="scrollArea" ng-controller="ScrollController">
  <a ng-click="gotoBottom()">Go to bottom</a>
  <a id="bottom"></a> You're at the bottom!
</div>
</div>

CSS

#scrollArea {
  height: 280px;
  overflow: auto;
}

#bottom {
  display: block;
  margin-top: 2000px;
}

JavaScript

var app = angular.module("MY_APP", []);

app.controller('ScrollController', ['$scope', '$location', '$anchorScroll',
  function($scope, $location, $anchorScroll) {
    $scope.gotoBottom = function() {
      // set the location.hash to the id of
      // the element you wish to scroll to.
      $location.hash('bottom');

      // call $anchorScroll()
      //$anchorScroll();
    };
  }]);