Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Controller aliases conflict with inherited scopes #13240

Closed
KorinaGraber opened this issue Nov 3, 2015 · 2 comments
Closed

Controller aliases conflict with inherited scopes #13240

KorinaGraber opened this issue Nov 3, 2015 · 2 comments

Comments

@KorinaGraber
Copy link

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:

return parentGet(scope, locals);

@gkalpak
Copy link
Member

gkalpak commented Nov 3, 2015

I believe this is a duplicate of #13021 (and will (hopefully) be addressed with #13025).

@KorinaGraber
Copy link
Author

Yes, looks like the same issue. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants