3

这可能有点多余,但我查看了 stackoverflow 上处理 anchorScroll 中的 YOffset 的一些项目,并且我已经复制了 plunker,但我的应用程序仍然无法正常工作。我的应用程序中有许多控制器(此时大约有 15 个),它的设置如下:

var app = angular.module('myapp', [])

.run(['$anchorScroll', function($anchorScroll) {
  $anchorScroll.yOffset = 50;   
}])

...

.controller('blabla', function($scope, $http, $location, $anchorScroll) {
// this is the only controller that uses anchorScroll

  $scope.gotoPub = function(pub_nid) {
    var final_hash = 'n' + pub_nid;
    $location.hash(final_hash);
    $anchorScroll();
};

...

现在,无论我在“运行”方法中将 yOffset 设置为什么,可能是 5000、50、10000 等,它对实际滚动绝对没有影响......我在这里做错了什么明显的事情吗?

谢谢!!-J

4

0 回答 0