Open timkindberg opened 9 years ago
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 that. The child components were not ready yet.
Quick note: @Parent
is obsolete. Parent dependencies are unbound by default. In other words, if we ask for a dependency in a component it simply looks it up in the dependency injector tree until it finds one. @Host
is then used to restrict the lookup to the component's host. Not sure if that's something you want to support for isolated scope directives.
@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 notifications@github.com wrote:
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.
— Reply to this email directly or view it on GitHub https://github.com/hannahhoward/a1atscript/issues/22#issuecomment-136371352 .
/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: