-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some way to mimick the various dependency injections in ng2 (@Parent, @Query, etc) #22
Comments
Hey looking into this -- one challenge is the Component class you define functions internally as the NG1 Directive's controller. And in fact, required controllers in NG1 aren't injected till the link function :(. I'm still looking into how to work around this but it may require going to some internal NG1 private api's. |
Yeah we actually had some issue using $element in the class because of |
Quick note: |
@PascalPrecht we are looking into some of these other things over at the new ng-forward project. https://github.com/ngUpgraders/ng-forward |
So this repo here is deprecated? |
No. The other one is not ready and definitely takes learnings from all of the existing 'ng2 polyfill' repos, but I could see each living on in its own way. We still use a1atscript at work. |
alright gotcha. On Mon, Aug 31, 2015 at 4:29 PM, Tim Kindberg [email protected]
/pp |
See: https://angular.io/docs/js/latest/api/annotations/DirectiveAnnotation-class.html. There are various dependencies you can inject into the controller class constructor.
directive:DirectiveType
: a directive on the current element only@Ancestor() directive:DirectiveType
: any directive that matches the type between the current element and the Shadow DOM root. Current element is not included in the resolution, therefore even if it could resolve it, it will be ignored.@Parent() directive:DirectiveType
: any directive that matches the type on a direct parent element only.@Query(DirectiveType) query:QueryList<DirectiveType>
: A live collection of direct child directives.@QueryDescendants(DirectiveType) query:QueryList<DirectiveType>
: A live collection of any child directives.In angular 1:
require: 'dependency'
. So no implementation needed.Thoughts on 4 & 5: Perhaps an api like this would be possible, where we auto-generate a $Query method on every component class that would help with this:
The text was updated successfully, but these errors were encountered: