File tree 2 files changed +34
-1
lines changed
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -349,7 +349,7 @@ function $CompileProvider($provide) {
349
349
var newScopeDirective ;
350
350
var newIsolateScopeDirective = previousCompileContext . newIsolateScopeDirective ;
351
351
var templateDirective = previousCompileContext . templateDirective ;
352
- var controllerDirectives ;
352
+ var controllerDirectives = previousCompileContext . controllerDirectives ;
353
353
354
354
function getControllers ( require , $element ) {
355
355
if ( _ . isArray ( require ) ) {
@@ -447,6 +447,7 @@ function $CompileProvider($provide) {
447
447
{
448
448
templateDirective : templateDirective ,
449
449
newIsolateScopeDirective : newIsolateScopeDirective ,
450
+ controllerDirectives : controllerDirectives ,
450
451
preLinkFns : preLinkFns ,
451
452
postLinkFns : postLinkFns
452
453
}
Original file line number Diff line number Diff line change @@ -2418,6 +2418,38 @@ describe('$compile', function() {
2418
2418
} ) ;
2419
2419
} ) ;
2420
2420
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
+
2421
2453
} ) ;
2422
2454
2423
2455
} ) ;
You can’t perform that action at this time.
0 commit comments