2013-08-01 67 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()'重新啓動進程。 –