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

Expose required controllers to a directive's controller #13041

Closed
abyx opened this issue Oct 7, 2015 · 1 comment
Closed

Expose required controllers to a directive's controller #13041

abyx opened this issue Oct 7, 2015 · 1 comment

Comments

@abyx
Copy link

abyx commented Oct 7, 2015

Currently you use controllers on directives to expose functionality. Then other directives use those controllers by supplying require and getting the controllers in the link function.

This feels asymmetric and a more natural way would be to allow the injection of required controllers to the directive's controller as well. That would mean that for a lot of use cases would could simply write directives with just the controller function and no need to pass it awkwardly from link to controller.

I was thinking about something like providing a $requires injectable for directive controllers that is basically an object, like $routeParams, from controller name to controller object.

If that sounds reasonable I'll work on a pull request.

@gkalpak
Copy link
Member

gkalpak commented Oct 7, 2015

Duplicate of #5893 and #12989.
Closing, since #5893 has more context/discussion.

(There is also PR #6040 addressing this, but it's too old now.)

@gkalpak gkalpak closed this as completed Oct 7, 2015
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