This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 1 file changed +29
-1
lines changed
1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change 10
10
* according to rules specified in
11
11
* {@link http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document Html5 spec}.
12
12
*
13
- * It also watches the `$location.hash()` and scroll whenever it changes to match any anchor.
13
+ * It also watches the `$location.hash()` and scrolls whenever it changes to match any anchor.
14
14
* This can be disabled by calling `$anchorScrollProvider.disableAutoScrolling()`.
15
+ *
16
+ * @example
17
+ <example>
18
+ <file name="index.html">
19
+ <div ng-controller="MainCtrl">
20
+ <a ng-click="gotoBottom()">Go to bottom</a>
21
+ <a id="bottom"></a> You're at the bottom!
22
+ </div>
23
+ </file>
24
+ <file name="script.js">
25
+ function ScrollCtrl($scope, $location, $anchorScroll) {
26
+ $scope.gotoBottom = function (){
27
+ // set the location.hash to the id of
28
+ // the element you wish to scroll to.
29
+ $location.hash('bottom');
30
+
31
+ // call $anchorScroll()
32
+ $anchorScroll();
33
+ }
34
+ }
35
+ </file>
36
+ <file name="style.css">
37
+ #bottom {
38
+ display: block;
39
+ margin-top: 2000px;
40
+ }
41
+ </file>
42
+ </example>
15
43
*/
16
44
function $AnchorScrollProvider ( ) {
17
45
You can’t perform that action at this time.
0 commit comments