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.

Require ?^ is broken: returns controllers on current element, instead of just its parents #6109

Closed
@jonrimmer

Description

@jonrimmer

The documentation has the following to say about the ?^ modifier on a directive's require parameter (emphasis mine):

?^ - Attempt to locate the required controller _by searching the element's parents_ or pass null to the link fn if not found.

However, if a directive is nested within itself, such as in a recursive menu structure, the require will find its own controller, rather than searching through its parents. E.g.

<menu-item label="Top Level">
  <menu-item label="Sub Level"></menu-item>
</menu-item>

The if the sub level menu item requires the ?^menuItem controller, it should get passed its parent controller via the link function. This is vital for basic use-cases around nestable controls that need to register and communicate with their parents. However, instead, it gets its own controller.

This problem is demonstrated in the following plunkr: http://plnkr.co/edit/76LU3c?p=preview

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions