
源码 index.html--11行,标示了的跳转ID:
<!DOCTYPE html><html ng-app="app"><head><script src="angular.min.js"></script><script src="app.js"></script><meta charset="utf-"></head><body ng-controller="MockController"><button ng-repeat="(key, value) in numbers" ng-click="jumper(key)"> {{key}} </button><div ng-repeat="(key, value) in numbers" id="{{key}}"><h>{{key}}</h><ol><ul ng-repeat="item in value"> {{item}} </ul></ol></div></body></html>app.jsvar demoApp = angular.module("app",[]).controller("MockController",function ($scope, $location, $anchorScroll) {$scope.numbers = {"自然数":["","","","","","","","","","","","","","","","","","","",""],"质数":["","","","","","", "", "", "", ""]};$scope.jumper = function(key){$location.hash(key);$anchorScroll();}});以上所述是小编给大家整理的AngularJS模块学习之Anchor Scroll 的相关内容,希望大家喜欢。