From d63462336d042d2c9670663c6e8b211b8e210a54 Mon Sep 17 00:00:00 2001 From: austinoneil Date: Wed, 7 Sep 2016 22:20:25 -0600 Subject: [PATCH 1/2] fix($compile):remove controllerAs requirement Remove the controllerAs requirement when binding a directive to a controller --- src/ng/compile.js | 5 ----- test/ng/compileSpec.js | 10 ++++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 47fc44c2e053..e7ab2c9ae0ab 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1035,11 +1035,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { throw $compileMinErr('noctrl', 'Cannot bind to controller without directive \'{0}\'s controller.', directiveName); - } else if (!identifierForController(controller, controllerAs)) { - // There is a controller, but no identifier or controllerAs property - throw $compileMinErr('noident', - 'Cannot bind to controller without identifier for directive \'{0}\'.', - directiveName); } } return bindings; diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 4c57925ec5a1..5070dcb1100b 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -5869,7 +5869,7 @@ describe('$compile', function() { }); - it('should throw noident when missing controllerAs directive property', function() { + it('should not throw noident when missing controllerAs directive property', function() { module(function($compileProvider) { $compileProvider.directive('noIdent', valueFn({ templateUrl: 'test.html', @@ -5886,13 +5886,12 @@ describe('$compile', function() { inject(function($compile, $rootScope) { expect(function() { $compile('
')($rootScope); - }).toThrowMinErr('$compile', 'noident', - 'Cannot bind to controller without identifier for directive \'noIdent\'.'); + }).not.toThrow(); }); }); - it('should throw noident when missing controller identifier', function() { + it('should not throw noident when missing controller identifier', function() { module(function($compileProvider, $controllerProvider) { $controllerProvider.register('myCtrl', function() {}); $compileProvider.directive('noIdent', valueFn({ @@ -5910,8 +5909,7 @@ describe('$compile', function() { inject(function($compile, $rootScope) { expect(function() { $compile('
')($rootScope); - }).toThrowMinErr('$compile', 'noident', - 'Cannot bind to controller without identifier for directive \'noIdent\'.'); + }).not.toThrow(); }); }); From 329d3a7b8ce01644aca1b235df0afeb7ef319728 Mon Sep 17 00:00:00 2001 From: austinoneil Date: Wed, 7 Sep 2016 23:05:08 -0600 Subject: [PATCH 2/2] Travis fixes --- src/ng/compile.js | 1 - test/ng/compileSpec.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 174c9ea1ef7f..4baeff6ca75d 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1029,7 +1029,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { } if (isObject(bindings.bindToController)) { var controller = directive.controller; - var controllerAs = directive.controllerAs; if (!controller) { // There is no controller, there may or may not be a controllerAs property throw $compileMinErr('noctrl', diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 823756def090..9c86cf021a23 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -5832,7 +5832,7 @@ describe('$compile', function() { $rootScope.remoteData = { 'foo': 'bar', 'baz': 'biz' - }); + }; expect(this.str).toBe('Hello, world!'); expect(this.fn()).toBe('called!'); controllerCalled = true;