Directive could not find parent directive's controller after upgrading from AngularJS 1.1.5 to 1.2.0

423 views
Skip to first unread message

Florian Bernstein

unread,
Nov 12, 2013, 4:26:59 AM11/12/13
to ang...@googlegroups.com
Hello everyone

While upgrading an application from AngularJS version 1.1.5 to 1.2.0 I ran into some issues which are related to inter-directive communication, done via directive's controller. In the application there's a parent directive and a child directive. At a certain point the child directive has to call a method of its parent directive's controller. Therefore the parent directive is marked as required in the child directive. One specialty about this scenario is that the parent directive uses a template which contains an ng-include directive to dynamically load a template which uses the child directive. 

When running on version 1.2.0 the child directive throws an error with the following message: "Controller 'xxx', required by directive 'yyy', can't be found!" 
After debugging and some more investigation I think the problem is related to the ng-include directive, but I'm not 100% sure why it doesn't work any more with version 1.2.0. 

I managed to reproduce the problem on Plunker : http://plnkr.co/edit/nOXE26ytUQpk40Wm3Cpl   
In the example I currently use version 1.2.0 so it won't work but you can easily switch to version 1.1.5 to see how it should work.  

So hopefully someone can help me solving this issue, I also want to understand what changed and way this behaviour happens with the new version as the concept how the directives are currently used is essential to the application. 

Best Regards,
Florian 

OpenNota

unread,
Nov 12, 2013, 8:48:59 AM11/12/13
to ang...@googlegroups.com
I believe this is a bug. However the responsible commit https://github.com/angular/angular.js/commit/aa2133ad message says about breaking change, it does not state, that it should break parent controller lookup. I would recommend you to report this to the developers.

OpenNota

unread,
Nov 12, 2013, 8:57:51 AM11/12/13
to ang...@googlegroups.com
And yes, error is thrown only when replace: true in the main directive definition.

Sander Elias

unread,
Nov 15, 2013, 4:59:37 AM11/15/13
to ang...@googlegroups.com
Hi Florian,

You did indeed hit a bug, will be fixed in 1.2.1! that will be out any time soon now.
have a look at: http://plnkr.co/edit/Mg7tDrlhkUXj0i2ge8DZ?p=preview

Regards
Sander

Florian Bernstein

unread,
Nov 15, 2013, 5:42:25 AM11/15/13
to ang...@googlegroups.com
Hi Sander, 

yeah I know. Actually I filed the bug. ;) 
But thanks anyway. 

Regards,
Florian

OpenNota

unread,
Nov 15, 2013, 7:02:17 AM11/15/13
to ang...@googlegroups.com
Funnily enough, they did git bisect wrong: https://github.com/angular/angular.js/issues/4935#issuecomment-28421751

Nevertheless, they fixed it promptly. This is good.

Reply all
Reply to author
Forward
0 new messages