2013-08-01 70 views
2

我想在$location更改前运行一个转换,在香草JS中,我可以选择不处理onhashchangepushstate更新,直到我准备好了,但是如何在AngularJS中实现此目标?

回答

2

看看$ locationChangeStart(还有很多其他的活动,你可能想看看还有:$ locationChangeSuccess,$ includeContentLoaded,$ viewContentLoaded,$ routeChangeStart,$ routeChangeError,$路由更新,$ routeChangeSuccess

$scope.$on("$locationChangeStart", function (event, nextLocation, currentLocation) { 
    // Do things here and then you can use event.preventDefault() 
}); 
+0

谢谢,我会试试看。此外,我想我会通过调用'$ routes.reload()'重新启动进程。 –