diff --git a/src/auto/injector.js b/src/auto/injector.js index 4f37214da526..84c8e3e06c30 100644 --- a/src/auto/injector.js +++ b/src/auto/injector.js @@ -441,7 +441,7 @@ function createInjector(modulesToLoad) { } function provider(name, provider_) { - if (isFunction(provider_)) { + if (isArray(provider_) || isFunction(provider_)) { provider_ = providerInjector.instantiate(provider_); } if (!provider_.$get) { diff --git a/test/auto/injectorSpec.js b/test/auto/injectorSpec.js index d2a637893363..5106c504bab9 100644 --- a/test/auto/injectorSpec.js +++ b/test/auto/injectorSpec.js @@ -394,6 +394,17 @@ describe('injector', function() { }); + it('should configure $provide using an array', function() { + function Type() {}; + Type.prototype.$get = function() { + return 'abc'; + }; + expect(createInjector([function($provide) { + $provide.provider('value', [Type]); + }]).get('value')).toEqual('abc'); + }); + + it('should configure a set of providers', function() { expect(createInjector([function($provide) { $provide.provider({value: valueFn({$get:Array})});