【发布时间】:2015-08-25 15:43:54
【问题描述】:
我有以下代码
$scope.scrollTo = function(id) {
alog($location.hash());
var toScrollId = "anchor" + id;
if($location.hash() !== toScrollId){
alog(" hash is not equal")
$location.hash(toScrollId);
}else{
alog(" hash is equal")
$anchorScroll();
}
};
html 看起来像
<button ng-click="scrollTo(raceid)">GO TO THIS</button>
<div ng-repeat="race in races" id="{{ 'anchor' + race.raceId}}">
</div>
但滚动总是到页面顶部。我做错了什么?
【问题讨论】:
-
你找到解决这个问题的方法了吗?