From e31d1c287d972d633bdaf9c385d3012192f64918 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 15 Feb 2012 21:49:07 -0800 Subject: refactor($route): remove .parent(); ng:view scope creation --- src/widgets.js | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'src/widgets.js') diff --git a/src/widgets.js b/src/widgets.js index 613ae1b4..bc41d761 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -498,23 +498,23 @@ var ngNonBindableDirective = valueFn({ terminal: true }); * * * @example - + -
+
overview | bootstrap | undefined @@ -538,14 +538,18 @@ var ngNonBindableDirective = valueFn({ terminal: true }); */ var ngViewDirective = ['$http', '$templateCache', '$route', '$anchorScroll', '$compile', - function($http, $templateCache, $route, $anchorScroll, $compile) { + '$controller', + function($http, $templateCache, $route, $anchorScroll, $compile, + $controller) { return { terminal: true, link: function(scope, element) { var changeCounter = 0; - scope.$on('$afterRouteChange', function() { + processRoute($route.current); + scope.$on('$afterRouteChange', function(event, next) { changeCounter++; + processRoute(next); }); scope.$watch(function() {return changeCounter;}, function(newChangeCounter) { @@ -571,6 +575,15 @@ var ngViewDirective = ['$http', '$templateCache', '$route', '$anchorScroll', '$c clearContent(); } }); + + function processRoute(route) { + if (route) { + route.scope = scope.$new(); + if (route.controller) { + $controller(route.controller, {$scope: route.scope}); + } + } + } } }; }]; -- cgit v1.2.3