diff options
| author | Ben Lesh | 2013-09-05 08:31:58 +0100 | 
|---|---|---|
| committer | Pete Bacon Darwin | 2013-09-05 08:34:35 +0100 | 
| commit | e7cfa5c2bf0dbb9e389700fd93433008d013a2ea (patch) | |
| tree | 17c7577b4edab0cbf249ab9436ce228df1fd4978 /src | |
| parent | 2a3212a0a333ee4c0640c6b6d63d3c5c34a81c70 (diff) | |
| download | angular.js-e7cfa5c2bf0dbb9e389700fd93433008d013a2ea.tar.bz2 | |
docs($anchorScroll): provide an example of basic usage.
Per a request made by Peter Bacon Darwin here:  http://www.benlesh.com/2013/02/angular-js-scrolling-to-element-by-id.html?showComment=1370941217879#c8718313084813008967
Diffstat (limited to 'src')
| -rw-r--r-- | src/ng/anchorScroll.js | 30 | 
1 files changed, 29 insertions, 1 deletions
| diff --git a/src/ng/anchorScroll.js b/src/ng/anchorScroll.js index 0ddc9c78..a87995cf 100644 --- a/src/ng/anchorScroll.js +++ b/src/ng/anchorScroll.js @@ -10,8 +10,36 @@   * according to rules specified in   * {@link http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document Html5 spec}.   * - * It also watches the `$location.hash()` and scroll whenever it changes to match any anchor. + * It also watches the `$location.hash()` and scrolls whenever it changes to match any anchor.   * This can be disabled by calling `$anchorScrollProvider.disableAutoScrolling()`. + *  + * @example +   <example> +     <file name="index.html"> +       <div ng-controller="MainCtrl"> +         <a ng-click="gotoBottom()">Go to bottom</a> +         <a id="bottom"></a> You're at the bottom! +       </div> +     </file> +     <file name="script.js"> +       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(); +         } +       } +     </file> +     <file name="style.css"> +       #bottom { +         display: block; +         margin-top: 2000px; +       } +     </file> +   </example>   */  function $AnchorScrollProvider() { | 
