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

Controller aliases conflict with inherited scopes #13240

Closed
@KorinaGraber

Description

@KorinaGraber

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions