diff options
| author | Misko Hevery | 2012-02-15 21:49:07 -0800 |
|---|---|---|
| committer | Vojta Jina | 2012-02-28 17:46:58 -0800 |
| commit | e31d1c287d972d633bdaf9c385d3012192f64918 (patch) | |
| tree | 8d975aecfcc56b049ded9d3a18f2f226d2c490fd /src/service/route.js | |
| parent | f16bd2f747ed94547eabdc4c337775a22a365255 (diff) | |
| download | angular.js-e31d1c287d972d633bdaf9c385d3012192f64918.tar.bz2 | |
refactor($route): remove .parent(); ng:view scope creation
Diffstat (limited to 'src/service/route.js')
| -rw-r--r-- | src/service/route.js | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/service/route.js b/src/service/route.js index 7cdcfd05..b7f8bd02 100644 --- a/src/service/route.js +++ b/src/service/route.js @@ -135,8 +135,8 @@ function $RouteProvider(){ }; - this.$get = ['$rootScope', '$location', '$routeParams', '$controller', - function( $rootScope, $location, $routeParams, $controller) { + this.$get = ['$rootScope', '$location', '$routeParams', + function( $rootScope, $location, $routeParams) { /** * @ngdoc event * @name angular.module.ng.$route#$beforeRouteChange @@ -185,7 +185,6 @@ function $RouteProvider(){ */ var matcher = switchRouteMatcher, - parentScope = $rootScope, dirty = 0, forceReload = false, $route = { @@ -193,22 +192,6 @@ function $RouteProvider(){ /** * @ngdoc method - * @name angular.module.ng.$route#parent - * @methodOf angular.module.ng.$route - * - * @param {Scope} [scope=rootScope] Scope to be used as parent for newly created - * `$route.current.scope` scopes. - * - * @description - * Sets a scope to be used as the parent scope for scopes created on route change. If not - * set, defaults to the root scope. - */ - parent: function(scope) { - if (scope) parentScope = scope; - }, - - /** - * @ngdoc method * @name angular.module.ng.$route#reload * @methodOf angular.module.ng.$route * @@ -266,7 +249,10 @@ function $RouteProvider(){ } else { forceReload = false; $rootScope.$broadcast('$beforeRouteChange', next, last); - last && last.scope && last.scope.$destroy(); + if (last && last.scope) { + last.scope.$destroy(); + last.scope = null; + } $route.current = next; if (next) { if (next.redirectTo) { @@ -279,10 +265,6 @@ function $RouteProvider(){ } } else { copy(next.params, $routeParams); - next.scope = parentScope.$new(); - if (next.controller) { - $controller(next.controller, {$scope: next.scope}); - } } } $rootScope.$broadcast('$afterRouteChange', next, last); |
