aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMisko Hevery2012-03-15 13:41:06 -0700
committerMisko Hevery2012-03-19 11:35:09 -0700
commit21e74c2d2e8e985b23711785287feb59965cbd90 (patch)
treef795363c0183df399c655b42ffd81b806e4e6c06 /test
parent6c5a05ad49a1e083570c3dfe331403398f899dbe (diff)
downloadangular.js-21e74c2d2e8e985b23711785287feb59965cbd90.tar.bz2
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.
Diffstat (limited to 'test')
-rw-r--r--test/directive/ngViewSpec.js29
1 files changed, 29 insertions, 0 deletions
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, '<div>{{state}}</div>', {}]);
+
+ $location.url('/foo');
+ $rootScope.$digest();
+ expect(element.text()).toEqual('WORKS');
+
+ var div = element.find('div');
+ expect(nodeName_(div.parent())).toEqual('NG:VIEW');
+
+ expect(div.scope()).toBe($route.current.scope);
+ expect(div.scope().hasOwnProperty('state')).toBe(true);
+ expect(div.scope().state).toEqual('WORKS');
+
+ expect(div.controller()).toBe($route.current.scope.ctrl);
+ });
+ });
});