Improve this doc View Source

When called, it checks current value of `$location.hash()` and scrolls to the related element, according to rules specified in Html5 spec.

It also watches the `$location.hash()` and scrolls whenever it changes to match any anchor. This can be disabled by calling `$anchorScrollProvider.disableAutoScrolling()`.

## Dependencies

- `$window`
- `$location`
- `$rootScope`

## Usage

`$anchorScroll();`

## Example

Edit in Plunker

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

    function ScrollCtrl($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();
      };
    }

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

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