ngParty / ng-metadata

Angular 2 decorators and utils for Angular 1.x
https://hotell.gitbooks.io/ng-metadata/content/
MIT License
355 stars 46 forks source link

queries field for @Component and @Directive #186

Open sliultron opened 7 years ago

sliultron commented 7 years ago

Can anyone please help and provide some example of using queries field? I try to use ViewChild to get the myChildComponent reference within the rootComponent class. However, it always returns undefined in ngAfterViewInit and ngAfterViewChecked

on the documentation, it says better to use queries field. However, there is no further example for that.
Any help is appreciated. Thanks

Hotell commented 7 years ago

Hey! can you provide a Plnkr pls or some code example? thanks!

Hotell commented 7 years ago

also using queries is not recommended if you wanna query anything within dynamic scope ( content within ngIf or ngRepeat etc ), because those things are not guaranteed to be present, so it will return undefined most of the time