【问题标题】:new angular router - autoscroll equivalent新的角度路由器 - 等效自动滚动
【发布时间】:2015-07-17 03:03:42
【问题描述】:

ui-router 和 1.4 角度路由器支持 autoscroll="true" 以使页面在导航到另一条路线时滚动到页面顶部。有谁知道如何使用new angular router 做到这一点?

ng-outlet 似乎没有自动滚动属性,并且路由器本身似乎没有任何我可以收听的事件,因此我可以手动连接。

【问题讨论】:

    标签: angularjs angular-new-router


    【解决方案1】:

    手动的方法是:

    $rootScope.$on('$locationChangeSuccess', function() {
      document.body.scrollTop = document.documentElement.scrollTop = 0;
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-22
      • 2022-07-12
      • 2021-05-17
      • 2019-01-16
      • 2018-08-04
      • 1970-01-01
      • 2021-06-04
      相关资源
      最近更新 更多