File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -349,7 +349,7 @@ function $CompileProvider($provide) {
349349 var newScopeDirective ;
350350 var newIsolateScopeDirective = previousCompileContext . newIsolateScopeDirective ;
351351 var templateDirective = previousCompileContext . templateDirective ;
352- var controllerDirectives ;
352+ var controllerDirectives = previousCompileContext . controllerDirectives ;
353353
354354 function getControllers ( require , $element ) {
355355 if ( _ . isArray ( require ) ) {
@@ -447,6 +447,7 @@ function $CompileProvider($provide) {
447447 {
448448 templateDirective : templateDirective ,
449449 newIsolateScopeDirective : newIsolateScopeDirective ,
450+ controllerDirectives : controllerDirectives ,
450451 preLinkFns : preLinkFns ,
451452 postLinkFns : postLinkFns
452453 }
Original file line number Diff line number Diff line change @@ -2418,6 +2418,38 @@ describe('$compile', function() {
24182418 } ) ;
24192419 } ) ;
24202420
2421+ it ( 'sets up controllers for all controller directives' , function ( ) {
2422+ var myDirectiveControllerInstantiated , myOtherDirectiveControllerInstantiated ;
2423+ var injector = makeInjectorWithDirectives ( {
2424+ myDirective : function ( ) {
2425+ return {
2426+ controller : function MyDirectiveController ( ) {
2427+ myDirectiveControllerInstantiated = true ;
2428+ }
2429+ } ;
2430+ } ,
2431+ myOtherDirective : function ( ) {
2432+ return {
2433+ templateUrl : '/my_other_directive.html' ,
2434+ controller : function MyOtherDirectiveController ( ) {
2435+ myOtherDirectiveControllerInstantiated = true ;
2436+ }
2437+ } ;
2438+ }
2439+ } ) ;
2440+ injector . invoke ( function ( $compile , $rootScope ) {
2441+ var el = $ ( '<div my-directive my-other-directive></div>' ) ;
2442+
2443+ $compile ( el ) ( $rootScope ) ;
2444+ $rootScope . $apply ( ) ;
2445+
2446+ requests [ 0 ] . respond ( 200 , { } , '<div></div>' ) ;
2447+
2448+ expect ( myDirectiveControllerInstantiated ) . toBe ( true ) ;
2449+ expect ( myOtherDirectiveControllerInstantiated ) . toBe ( true ) ;
2450+ } ) ;
2451+ } ) ;
2452+
24212453 } ) ;
24222454
24232455} ) ;
You can’t perform that action at this time.
0 commit comments