From 21e74c2d2e8e985b23711785287feb59965cbd90 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 15 Mar 2012 13:41:06 -0700 Subject: fix(ngView): controller not published corrected omitted assignment of controller to the element data object. Without this fix the controller created by ngView is not accessible from the browser debugger. --- src/directive/ngView.js | 3 ++- test/directive/ngViewSpec.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/directive/ngView.js b/src/directive/ngView.js index d5b24bcb..95b1546d 100644 --- a/src/directive/ngView.js +++ b/src/directive/ngView.js @@ -149,7 +149,8 @@ var ngViewDirective = ['$http', '$templateCache', '$route', '$anchorScroll', '$c lastScope = current.scope = scope.$new(); if (current.controller) { - $controller(current.controller, {$scope: lastScope}); + element.contents(). + data('$ngControllerController', $controller(current.controller, {$scope: lastScope})); } link(lastScope); diff --git a/test/directive/ngViewSpec.js b/test/directive/ngViewSpec.js index bf3706ac..52aefa3a 100644 --- a/test/directive/ngViewSpec.js +++ b/test/directive/ngViewSpec.js @@ -408,4 +408,33 @@ describe('ng-view', function() { expect($rootScope.load).toHaveBeenCalledOnce(); }); }) + + + it('should set $scope and $controllerController on the view', function() { + function MyCtrl($scope) { + $scope.state = 'WORKS'; + $scope.ctrl = this; + } + + module(function($routeProvider) { + $routeProvider.when('/foo', {template: 'tpl.html', controller: MyCtrl}); + }); + + inject(function($templateCache, $location, $rootScope, $route) { + $templateCache.put('tpl.html', [200, '