-
Notifications
You must be signed in to change notification settings - Fork 27.4k
1.5 Component() syntax and Directive required controllers #13746
Comments
Adding support for injecting required controllers into the directive's controller is tracked in #5893 (but there are certain difficulties). I don't think ng2's ViewQuery is similar to ng1's Are you suggesting ng1 should have something similar as ng2's ViewQuery ? |
Doing this as a special version of Dependency Injector (compoenent aware injector) would be most elegant way. We can make it simillar to router 'resolve' config, where you could Resolve the components you want, use keys as names and then simply inject required controllers using those keys into your controller. Two ways to approach this:
Of course having both would be awsome. ;-) But i guess its a question of eitiher just making ng1 more usable or focusing on migration path to ng2 and making it work simillar to ng2. Querying children makes some potentially complex things with notyfying you on every ng-repeat there is so you get up-to-date directives instances list ( i.e. this.panes.listen(...) ) where querying parents its stable in that manner - you cant remove parent compoenent without removing your component first. |
Optional requires might be tricky though... you can't have optional DI instances.. unless we can inject just 'undefined' to controller in case require parent controller doesnt exists? |
Let's move the discussion to #5893 |
Hello,
I started using module.component() syntax for my directives and it works well, its clean and saves a lot of typing.
The only issue i have is that i used a lot the directives with "require" for inter-directive communication.
Is there a roadmap for adding this to component() syntax. I know for angular2 there are component queries ( https://angular.io/docs/js/latest/api/core/DirectiveMetadata-class.html ) - some limited version of that would be great for smooth migration path as currently one can use plain old directives with require or "solve" it with lot of
Something in lines of :
or
Would be very useful and is somewhat vaguely simillar to:
Are there any working docs on 1.x directive -> 2.x compoenent migration work i could follow and contribute maybe?
The text was updated successfully, but these errors were encountered: