| 2904 | } |
| 2905 | |
| 2906 | function instantiate(Type, locals) { |
| 2907 | var Constructor = function() {}, |
| 2908 | instance, returnedValue; |
| 2909 | |
| 2910 | // Check if Type is annotated and use just the given function at n-1 as parameter |
| 2911 | // e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]); |
| 2912 | Constructor.prototype = (isArray(Type) ? Type[Type.length - 1] : Type).prototype; |
| 2913 | instance = new Constructor(); |
| 2914 | returnedValue = invoke(Type, instance, locals); |
| 2915 | |
| 2916 | return isObject(returnedValue) ? returnedValue : instance; |
| 2917 | } |
| 2918 | |
| 2919 | return { |
| 2920 | invoke: invoke, |