Skip to content
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 opened this issue Feb 4, 2014 · 1 comment

Comments

@jonrimmer
Copy link

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

@caitp
Copy link
Contributor

caitp commented Feb 4, 2014

This is a dupe of #4518 (so lets move the discussion over there!)

@caitp caitp closed this as completed Feb 4, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants