Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(injector) Fixes #1452: Provider can't be configured with an array #1601

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/auto/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions test/auto/injectorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})});
Expand Down