Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit d279545

Browse files
fix($compile): don't throw if controller is named
1 parent b54634d commit d279545

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/ng/compile.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
11241124
forEach(options, function(val, key) {
11251125
if (key.charAt(0) === '$') {
11261126
factory[key] = val;
1127-
controller[key] = val;
1127+
// Don't try to copy over annotations to named controller
1128+
if (isFunction(controller)) controller[key] = val;
11281129
}
11291130
});
11301131

test/ng/compileSpec.js

+11
Original file line numberDiff line numberDiff line change
@@ -10509,6 +10509,17 @@ describe('$compile', function() {
1050910509
});
1051010510
});
1051110511

10512+
it('should support custom annotations if the controller is named', function() {
10513+
var myModule = angular.module('my', []).component('myComponent', {
10514+
$customAnnotation: 'XXX',
10515+
controller: 'SomeNamedController'
10516+
});
10517+
module('my');
10518+
expect(function() {
10519+
inject(function(myComponentDirective) {});
10520+
}).not.toThrow();
10521+
});
10522+
1051210523
it('should return ddo with reasonable defaults', function() {
1051310524
angular.module('my', []).component('myComponent', {});
1051410525
module('my');

0 commit comments

Comments
 (0)