html:在需要跳轉(zhuǎn)的地方添加scrollTo()參數(shù)是跳轉(zhuǎn)的id.
<a href="" ng-click="scrollTo('foo')">Scroll to #foo</a>
<div id="foo">
This is #foo
</div>
JavaScript: 在你的控制器完成你的跳轉(zhuǎn)操作.(這需要聲明$location, $anchorScroll)
app.controller('MainCtrl', function($scope, $location, $anchorScroll, $routeParams) {
$scope.scrollTo = function(id) {
$location.hash(id);
$anchorScroll();
}
});