AJS - Services $anchorScroll
$anchorScroll ये service; $location.hash() function पर दिए गए id के मुताबिक उसके called पर scroll किया जाता है |
$anchorScrollProvider.disableAutoScrolling() को call करने पर $anchorScroll ये service disabled हो जाती है |
Example for $anchorScroll Service in AngularJS
Source Code :Output :<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <style> .down{ margin-top:2000px; } </style> </head> <body> <div ng-app="app" ng-controller="ASctrl"> <a href="" id="top" ng-click="toDown()">Click to go to Down</a> <div class="down"> <a href="" id="down" ng-click="toTop()">Click to go to Up</a> </div> </div> <script> var app = angular.module("app",[]); app.controller("ASctrl",['$location','$anchorScroll','$scope', function ($location, $anchorScroll,$scope){ $scope.toTop = function(){ $location.hash('top'); $anchorScroll(); } $scope.toDown = function(){ $location.hash('down'); $anchorScroll(); } }]); </script> </body> </html>