File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -441,7 +441,7 @@ function createInjector(modulesToLoad) {
441
441
}
442
442
443
443
function provider ( name , provider_ ) {
444
- if ( isFunction ( provider_ ) ) {
444
+ if ( isFunction ( provider_ ) || isArray ( provider_ ) ) {
445
445
provider_ = providerInjector . instantiate ( provider_ ) ;
446
446
}
447
447
if ( ! provider_ . $get ) {
Original file line number Diff line number Diff line change @@ -394,6 +394,20 @@ describe('injector', function() {
394
394
} ) ;
395
395
396
396
397
+ it ( 'should configure $provide using an array' , function ( ) {
398
+ function Type ( PREFIX ) {
399
+ this . prefix = PREFIX ;
400
+ } ;
401
+ Type . prototype . $get = function ( ) {
402
+ return this . prefix + 'def' ;
403
+ } ;
404
+ expect ( createInjector ( [ function ( $provide ) {
405
+ $provide . constant ( 'PREFIX' , 'abc' ) ;
406
+ $provide . provider ( 'value' , [ 'PREFIX' , Type ] ) ;
407
+ } ] ) . get ( 'value' ) ) . toEqual ( 'abcdef' ) ;
408
+ } ) ;
409
+
410
+
397
411
it ( 'should configure a set of providers' , function ( ) {
398
412
expect ( createInjector ( [ function ( $provide ) {
399
413
$provide . provider ( { value : valueFn ( { $get :Array } ) } ) ;
You can’t perform that action at this time.
0 commit comments