diff options
| author | Misko Hevery | 2011-10-17 16:56:56 -0700 |
|---|---|---|
| committer | Misko Hevery | 2011-11-14 16:39:31 -0800 |
| commit | 48697a2b86dbb12ea8de64cc5fece7caf68b321e (patch) | |
| tree | 1fa50659f0bb5de2640dea2a2e5bb5628f2bb14a /src/service/route.js | |
| parent | 93b777c916ccff243c5a6080bf5f39860ac7bf39 (diff) | |
| download | angular.js-48697a2b86dbb12ea8de64cc5fece7caf68b321e.tar.bz2 | |
refactor(injector): turn scope into a service
- turn scope into a $rootScope service.
- injector is now a starting point for creating angular application.
- added inject() method which wraps jasmine its/beforeEach/afterEach,
and which allows configuration and injection of services.
- refactor tests to use inject() where possible
BREAK:
- removed angular.scope() method
Diffstat (limited to 'src/service/route.js')
| -rw-r--r-- | src/service/route.js | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/service/route.js b/src/service/route.js index ddc3df49..3918c251 100644 --- a/src/service/route.js +++ b/src/service/route.js @@ -62,7 +62,7 @@ </doc:scenario> </doc:example> */ -angularServiceInject('$route', function($location, $routeParams) { +angularServiceInject('$route', function($rootScope, $location, $routeParams) { /** * @ngdoc event * @name angular.service.$route#$beforeRouteChange @@ -112,8 +112,7 @@ angularServiceInject('$route', function($location, $routeParams) { var routes = {}, matcher = switchRouteMatcher, - parentScope = this, - rootScope = this, + parentScope = $rootScope, dirty = 0, forceReload = false, $route = { @@ -220,7 +219,7 @@ angularServiceInject('$route', function($location, $routeParams) { } }; - this.$watch(function() { return dirty + $location.url(); }, updateRoute); + $rootScope.$watch(function() { return dirty + $location.url(); }, updateRoute); return $route; @@ -262,7 +261,7 @@ angularServiceInject('$route', function($location, $routeParams) { last.scope && last.scope.$emit('$routeUpdate'); } else { forceReload = false; - rootScope.$broadcast('$beforeRouteChange', next, last); + $rootScope.$broadcast('$beforeRouteChange', next, last); last && last.scope && last.scope.$destroy(); $route.current = next; if (next) { @@ -280,7 +279,7 @@ angularServiceInject('$route', function($location, $routeParams) { next.scope = parentScope.$new(Controller); } } - rootScope.$broadcast('$afterRouteChange', next, last); + $rootScope.$broadcast('$afterRouteChange', next, last); } } @@ -323,4 +322,4 @@ angularServiceInject('$route', function($location, $routeParams) { } -}, ['$location', '$routeParams']); +}, ['$rootScope', '$location', '$routeParams']); |
