2017-06-07 57 views
1

我非常接近完成了我的网页,我就遇到了这个奇怪的错误。

当我使用NG-包括,页面加载罚款,但他们继续从以前的位置滚动,这样他们就不会在每点击顶部开始。

我诉诸使用锚点滚动,但它不能正常工作。我必须再次单击该链接,才能加载内容,如果再次单击相同的链接,它会将页面偏移到某个奇怪的位置。

这是我在控制器代码:

$scope.toPage = function (index, id) { 
    $scope.missiveIndex = index; 
    $scope.contentsDown(); 
    $location.hash(id); 
}; 

,这是HTML部分:

<article id="{{articles.ids}}" class="stories-anim" ng-repeat="articles in stories" ng-hide="!isMissiveSlideIndex($index)" ng-include="articles.content" [autoscroll]> 
</article> 

的ID通过ng-click="ng-click="toPage($index, button.ids);"

传递是有放的方式[onload]表达式中的location.hash和autoscroll方式?

感谢

回答

0

大概锚滚动没有工作,因为页面的内容时,它被称为不完全加载。

您可以通过使用一个超时解决。

$timeout(function() { 
    $anchorScroll(); 
},500); 
+0

谢谢。我设法通过实际使用0秒超时对第一次加载进行破解。如果您回到上一篇文章,它会保留滚动位置 – Irakli