mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-06-19 17:53:27 +08:00
docs($anchorScroll): update example to use a module
This commit is contained in:
@@ -17,24 +17,26 @@
|
||||
* This can be disabled by calling `$anchorScrollProvider.disableAutoScrolling()`.
|
||||
*
|
||||
* @example
|
||||
<example>
|
||||
<example module="anchorScrollExample">
|
||||
<file name="index.html">
|
||||
<div id="scrollArea" ng-controller="ScrollCtrl">
|
||||
<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">
|
||||
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');
|
||||
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();
|
||||
};
|
||||
}
|
||||
// call $anchorScroll()
|
||||
$anchorScroll();
|
||||
};
|
||||
}]);
|
||||
</file>
|
||||
<file name="style.css">
|
||||
#scrollArea {
|
||||
|
||||
Reference in New Issue
Block a user