diff --git a/src/auto/injector.js b/src/auto/injector.js index 84b863b86031..cd47daa67f14 100644 --- a/src/auto/injector.js +++ b/src/auto/injector.js @@ -440,7 +440,7 @@ function createInjector(modulesToLoad) { } function provider(name, provider_) { - if (isFunction(provider_)) { + if (isFunction(provider_) || isArray(provider_)) { provider_ = providerInjector.instantiate(provider_); } if (!provider_.$get) { diff --git a/test/auto/injectorSpec.js b/test/auto/injectorSpec.js index 7e5c5d33f2b0..2f82d3b5c689 100644 --- a/test/auto/injectorSpec.js +++ b/test/auto/injectorSpec.js @@ -387,6 +387,20 @@ describe('injector', function() { }); + it('should configure $provide using an array', function() { + function Type(PREFIX) { + this.prefix = PREFIX; + }; + Type.prototype.$get = function() { + return this.prefix + 'def'; + }; + expect(createInjector([function($provide) { + $provide.constant('PREFIX', 'abc'); + $provide.provider('value', ['PREFIX', Type]); + }]).get('value')).toEqual('abcdef'); + }); + + it('should configure a set of providers', function() { expect(createInjector([function($provide) { $provide.provider({value: valueFn({$get:Array})});