Require ?^ is broken: returns controllers on current element, instead of just its parents #6109
Description
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