diff --git a/src/auto/injector.js b/src/auto/injector.js index d80a32dea39a..ac4465047b10 100644 --- a/src/auto/injector.js +++ b/src/auto/injector.js @@ -582,11 +582,31 @@ function createInjector(modulesToLoad) { } } + // Is Given function annotated like + // $injector.invoke(['serviceA', function(serviceA){}]) + function isInlineAnnotated(fn){ + return isArray(fn); + } + + // Get function of an annotated invoke description + function getAnnotatedFunction(fn){ + if(isInlineAnnotated(fn)){ + return fn[fn.length - 1] + } + else{ + return fn; + } + } + function instantiate(Type, locals) { var Constructor = function() {}, - instance, returnedValue; + annotatedFunction, + instance, + returnedValue; + + annotatedFunction = getAnnotatedFunction(Type); - Constructor.prototype = (isArray(Type) ? Type[Type.length - 1] : Type).prototype; + Constructor.prototype = annotatedFunction.prototype; instance = new Constructor(); returnedValue = invoke(Type, instance, locals);