Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 59c0901

Browse files
committed
docs($anchorScroll): update example to use a module
1 parent a88c215 commit 59c0901

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/ng/anchorScroll.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,26 @@
1717
* This can be disabled by calling `$anchorScrollProvider.disableAutoScrolling()`.
1818
*
1919
* @example
20-
<example>
20+
<example module="anchorScrollExample">
2121
<file name="index.html">
22-
<div id="scrollArea" ng-controller="ScrollCtrl">
22+
<div id="scrollArea" ng-controller="ScrollController">
2323
<a ng-click="gotoBottom()">Go to bottom</a>
2424
<a id="bottom"></a> You're at the bottom!
2525
</div>
2626
</file>
2727
<file name="script.js">
28-
function ScrollCtrl($scope, $location, $anchorScroll) {
29-
$scope.gotoBottom = function (){
30-
// set the location.hash to the id of
31-
// the element you wish to scroll to.
32-
$location.hash('bottom');
28+
angular.module('anchorScrollExample', [])
29+
.controller('ScrollController', ['$scope', '$location', '$anchorScroll',
30+
function ($scope, $location, $anchorScroll) {
31+
$scope.gotoBottom = function() {
32+
// set the location.hash to the id of
33+
// the element you wish to scroll to.
34+
$location.hash('bottom');
3335
34-
// call $anchorScroll()
35-
$anchorScroll();
36-
};
37-
}
36+
// call $anchorScroll()
37+
$anchorScroll();
38+
};
39+
}]);
3840
</file>
3941
<file name="style.css">
4042
#scrollArea {

0 commit comments

Comments
 (0)