【发布时间】:2017-06-07 02:41:44
【问题描述】:
我即将完成我的页面,但我遇到了这个奇怪的错误。
当我使用 ng-include 时,页面加载正常,但它们会从之前的位置继续滚动,因此它们不会在每次点击时从顶部开始。
我求助于使用锚滚动,但它不能正常工作。我必须再次单击该链接,它才能加载内容,如果我再次单击同一个链接,它会将页面偏移到某个奇怪的位置。
这是我在控制器中的代码:
$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);"传入的
有没有办法将 location.hash 放在 [onload] 表达式中并以这种方式自动滚动?
谢谢
【问题讨论】:
标签: angularjs autoscroll