From what I've read in the Angular 2 documentation of QueryList
, @Query
should allow for the ability to inject a reference to a child component into a given component.
Using @QueryView
I've managed to get a reference to a child DOM element like so:
// Parent component's template
<my-component #test>
// Parent component
class ParentComponent {
constructor(@Query('test') child: QueryList<any>) {...}
}
I expected that @Query
may return the matching component rather than the DOM element, but I haven't managed to get it working, nor have I found any documentation that indicates so.
What's the difference between these two decorators?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…