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