【发布时间】:2015-07-17 03:03:42
【问题描述】:
ui-router 和 1.4 角度路由器支持 autoscroll="true" 以使页面在导航到另一条路线时滚动到页面顶部。有谁知道如何使用new angular router 做到这一点?
ng-outlet 似乎没有自动滚动属性,并且路由器本身似乎没有任何我可以收听的事件,因此我可以手动连接。
【问题讨论】:
标签: angularjs angular-new-router
ui-router 和 1.4 角度路由器支持 autoscroll="true" 以使页面在导航到另一条路线时滚动到页面顶部。有谁知道如何使用new angular router 做到这一点?
ng-outlet 似乎没有自动滚动属性,并且路由器本身似乎没有任何我可以收听的事件,因此我可以手动连接。
【问题讨论】:
标签: angularjs angular-new-router
手动的方法是:
$rootScope.$on('$locationChangeSuccess', function() {
document.body.scrollTop = document.documentElement.scrollTop = 0;
});
【讨论】: