My page should scroll to top again after i change the page.
I have an angular1.6 page with page transitions & ui-router, so i cant use <div ui-view="main" autoscroll="true"></div>
. I tried the following code but its not even executing the console.log :/ :
angular.module("App", ["ngAnimate", "ui.router", "vcRecaptcha"]).run(["$rootScope", "$state", function(a, b) {
a.$on('$stateChangeSuccess',function(){
window.scrollTo(0,0);
console.log("foo");
})
}])
I tried routeChangeSuccess too ... any ideas?
Thanks in advance
答案 0 :(得分:1)
如果您使用的是新的ui-router(v1.0.0),$ stateChange *事件将无效。从现在开始,你必须使用$ transitions.on * hooks。