html:在需要跳转的地方添加scrollTo()
参数是跳转的id.
<a href="" ng-click="scrollTo('foo')">Scroll to #foo</a>
<div id="foo">
This is #foo
</div>
JavaScript: 在你的控制器完成你的跳转操作.(这需要声明$location, $anchorScroll
)
app.controller('MainCtrl', function($scope, $location, $anchorScroll, $routeParams) {
$scope.scrollTo = function(id) {
$location.hash(id);
$anchorScroll();
}
});