mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
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
This commit is contained in:
parent
9d6d3969f1
commit
7ed5599a4b
1 changed files with 29 additions and 1 deletions
|
|
@ -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() {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue