Controller aliases conflict with inherited scopes #13240
Description
I recently ran into an issue when using inherited scopes with controllerAs and bindToController. The situation is as follows:
The parent and child directives use the same controller alias (controllerAs: 'controller')
The child directive binds an action from the parent using an event binding. (bindToController: { action: '&' })
The child directive uses an inherited scope. (scope: true) This is important because the binding appears to work correctly with an isolate scope.
The parent directive binds a method from its controller to the child action. (action="controller.parentAction()")
When the child triggers a call to the action, the angular compiler incorrectly picks up the controller of the child directive instead of the parent, thus leading to a noop or an incorrect function call.
Plunkr: http://plnkr.co/edit/JRCoRIsDV3UpS6D2ELKa?p=preview
Angular Version: 1.4.5
I don't know exactly where the issue originates, but I do know the following line is hit with the child scope when the child tries to trigger the action:
Line 2765 in 96288d0