diff --git a/src/ng/compile.js b/src/ng/compile.js index b0d3cf1d..00f174d1 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1767,7 +1767,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { "Controller '{0}', required by directive '{1}', can't be found!", require, directiveName); } - return value; + return value || null; } else if (isArray(require)) { value = []; forEach(require, function(require) { diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 8e9fac55..294140bd 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -4197,38 +4197,38 @@ describe('$compile', function() { }); - it("should not throw an error if required controller can't be found and is optional",function() { + it("should pass null if required controller can't be found and is optional",function() { module(function() { directive('dep', function(log) { return { require: '?^main', link: function(scope, element, attrs, controller) { - log('dep:' + !!controller); + log('dep:' + controller); } }; }); }); inject(function(log, $compile, $rootScope) { $compile('