fix($compile): don't throw if controller is named

This commit is contained in:
Peter Bacon Darwin
2016-04-04 15:27:09 +01:00
parent b54634d37b
commit d27954575f
2 changed files with 13 additions and 1 deletions
+2 -1
View File
@@ -1124,7 +1124,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
forEach(options, function(val, key) {
if (key.charAt(0) === '$') {
factory[key] = val;
controller[key] = val;
// Don't try to copy over annotations to named controller
if (isFunction(controller)) controller[key] = val;
}
});
+11
View File
@@ -10509,6 +10509,17 @@ describe('$compile', function() {
});
});
it('should support custom annotations if the controller is named', function() {
var myModule = angular.module('my', []).component('myComponent', {
$customAnnotation: 'XXX',
controller: 'SomeNamedController'
});
module('my');
expect(function() {
inject(function(myComponentDirective) {});
}).not.toThrow();
});
it('should return ddo with reasonable defaults', function() {
angular.module('my', []).component('myComponent', {});
module('my');