@@ -5381,6 +5381,55 @@ describe('$compile', function() {
5381
5381
} ) ;
5382
5382
} ) ;
5383
5383
5384
+ it ( 'should bind required controllers to controller that has an explicit constructor return value' , function ( ) {
5385
+ var parentController , siblingController , meController ;
5386
+
5387
+ function ParentController ( ) { this . name = 'Parent' ; }
5388
+ function SiblingController ( ) { this . name = 'Sibling' ; }
5389
+ function MeController ( ) {
5390
+ meController = {
5391
+ name : 'Me' ,
5392
+ $onInit : function ( ) {
5393
+ parentController = this . container ;
5394
+ siblingController = this . friend ;
5395
+ }
5396
+ } ;
5397
+ spyOn ( meController , '$onInit' ) . andCallThrough ( ) ;
5398
+ return meController ;
5399
+ }
5400
+
5401
+ angular . module ( 'my' , [ ] )
5402
+ . directive ( 'me' , function ( ) {
5403
+ return {
5404
+ restrict : 'E' ,
5405
+ scope : { } ,
5406
+ require : { container : '^parent' , friend : 'sibling' } ,
5407
+ controller : MeController
5408
+ } ;
5409
+ } )
5410
+ . directive ( 'parent' , function ( ) {
5411
+ return {
5412
+ restrict : 'E' ,
5413
+ scope : { } ,
5414
+ controller : ParentController
5415
+ } ;
5416
+ } )
5417
+ . directive ( 'sibling' , function ( ) {
5418
+ return {
5419
+ controller : SiblingController
5420
+ } ;
5421
+ } ) ;
5422
+
5423
+ module ( 'my' ) ;
5424
+ inject ( function ( $compile , $rootScope , meDirective ) {
5425
+ element = $compile ( '<parent><me sibling></me></parent>' ) ( $rootScope ) ;
5426
+ expect ( meController . $onInit ) . toHaveBeenCalled ( ) ;
5427
+ expect ( parentController ) . toEqual ( jasmine . any ( ParentController ) ) ;
5428
+ expect ( siblingController ) . toEqual ( jasmine . any ( SiblingController ) ) ;
5429
+ } ) ;
5430
+ } ) ;
5431
+
5432
+
5384
5433
it ( 'should require controller of an isolate directive from a non-isolate directive on the ' +
5385
5434
'same element' , function ( ) {
5386
5435
var IsolateController = function ( ) { } ;
0 commit comments