From 92a2e1807657c69e1372106b0727675a30f4cbd7 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 22 May 2012 16:45:56 -0700 Subject: feat($location): add $locatonChange[begin|completed] event This allows location change cancelation --- src/ng/route.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/ng/route.js') diff --git a/src/ng/route.js b/src/ng/route.js index 032e3716..ec05d1f8 100644 --- a/src/ng/route.js +++ b/src/ng/route.js @@ -286,7 +286,6 @@ function $RouteProvider(){ */ var matcher = switchRouteMatcher, - dirty = 0, forceReload = false, $route = { routes: routes, @@ -304,12 +303,12 @@ function $RouteProvider(){ * creates new scope, reinstantiates the controller. */ reload: function() { - dirty++; forceReload = true; + $rootScope.$evalAsync(updateRoute); } }; - $rootScope.$watch(function() { return dirty + $location.url(); }, updateRoute); + $rootScope.$on('$locationChangeSuccess', updateRoute); return $route; -- cgit v1.2.3