function getFirstAnchor(list) {
      var result = null;
      Array.prototype.some.call(list, function(element) {
        if (nodeName_(element) === 'a') {
          result = element;
          return true;
        }
      });
      return result;
    }
@ngdoc service
@name $anchorScroll
@kind function
@requires $window
@requires $location
@requires $rootScope

@description
When called, it checks the current value of {@link ng.$location#hash $location.hash()} and
scrolls to the related element, according to the rules specified in the
[Html5 spec](http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document).

It also watches the {@link ng.$location#hash $location.hash()} and automatically scrolls to
match any anchor whenever it changes. This can be disabled by calling
{@link ng.$anchorScrollProvider#disableAutoScrolling $anchorScrollProvider.disableAutoScrolling()}.

Additionally, you can use its {@link ng.$anchorScroll#yOffset yOffset} property to specify a
vertical scroll-offset (either fixed or dynamic).

@property {(number|function|jqLite)} yOffset
If set, specifies a vertical scroll-offset. This is often useful when there are fixed
positioned elements at the top of the page, such as navbars, headers etc.

`yOffset` can be specified in various ways:
- **number**: A fixed number of pixels to be used as offset.<br /><br />
- **function**: A getter function called everytime `$anchorScroll()` is executed. Must return
  a number representing the offset (in pixels).<br /><br />
- **jqLite**: A jqLite/jQuery element to be used for specifying the offset. The distance from
  the top of the page to the element's bottom will be used as offset.<br />
  **Note**: The element will be taken into account only as long as its `position` is set to
  `fixed`. This option is useful, when dealing with responsive navbars/headers that adjust
  their height and/or positioning according to the viewport's size.

<br />
<div class="alert alert-warning">
In order for `yOffset` to work properly, scrolling should take place on the document's root and
not some child element.
</div>

@example
     <example module="anchorScrollExample">
       <file name="index.html">
         <div id="scrollArea" ng-controller="ScrollController">
           <a ng-click="gotoBottom()">Go to bottom</a>
           <a id="bottom"></a> You're at the bottom!
         </div>
       </file>
       <file name="script.js">
         angular.module('anchorScrollExample', [])
           .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();
               };
             }]);
       </file>
       <file name="style.css">
         #scrollArea {
           height: 280px;
           overflow: auto;
         }

         #bottom {
           display: block;
           margin-top: 2000px;
         }
       </file>
     </example>

<hr />
The example below illustrates the use of a vertical scroll-offset (specified as a fixed value).
See {@link ng.$anchorScroll#yOffset $anchorScroll.yOffset} for more details.

@example
     <example module="anchorScrollOffsetExample">
       <file name="index.html">
         <div class="fixed-header" ng-controller="headerCtrl">
           <a href="" ng-click="gotoAnchor(x)" ng-repeat="x in [1,2,3,4,5]">
             Go to anchor {{x}}
           </a>
         </div>
         <div id="anchor{{x}}" class="anchor" ng-repeat="x in [1,2,3,4,5]">
           Anchor {{x}} of 5
         </div>
       </file>
       <file name="script.js">
         angular.module('anchorScrollOffsetExample', [])
           .run(['$anchorScroll', function($anchorScroll) {
             $anchorScroll.yOffset = 50;   // always scroll by 50 extra pixels
           }])
           .controller('headerCtrl', ['$anchorScroll', '$location', '$scope',
             function ($anchorScroll, $location, $scope) {
               $scope.gotoAnchor = function(x) {
                 var newHash = 'anchor' + x;
                 if ($location.hash() !== newHash) {
                   // set the $location.hash to `newHash` and
                   // $anchorScroll will automatically scroll to it
                   $location.hash('anchor' + x);
                 } else {
                   // call $anchorScroll() explicitly,
                   // since $location.hash hasn't changed
                   $anchorScroll();
                 }
               };
             }
           ]);
       </file>
       <file name="style.css">
         body {
           padding-top: 50px;
         }

         .anchor {
           border: 2px dashed DarkOrchid;
           padding: 10px 10px 200px 10px;
         }

         .fixed-header {
           background-color: rgba(0, 0, 0, 0.2);
           height: 50px;
           position: fixed;
           top: 0; left: 0; right: 0;
         }

         .fixed-header > a {
           display: inline-block;
           margin: 5px 15px;
         }
       </file>
     </example>