File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -440,7 +440,7 @@ function createInjector(modulesToLoad) {
440440 }
441441
442442 function provider ( name , provider_ ) {
443- if ( isFunction ( provider_ ) ) {
443+ if ( isFunction ( provider_ ) || isArray ( provider_ ) ) {
444444 provider_ = providerInjector . instantiate ( provider_ ) ;
445445 }
446446 if ( ! provider_ . $get ) {
Original file line number Diff line number Diff line change @@ -387,6 +387,20 @@ describe('injector', function() {
387387 } ) ;
388388
389389
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+
390404 it ( 'should configure a set of providers' , function ( ) {
391405 expect ( createInjector ( [ function ( $provide ) {
392406 $provide . provider ( { value : valueFn ( { $get :Array } ) } ) ;
You can’t perform that action at this time.
0 commit comments