Reputation: 10156
I know I can use @ViewChild
to get a reference to some child of current component:
@ViewChild('someInput') someInput: ElementRef;
And inside the HTML
part:
<input #someInput />
But what if I wanted to get a reference for the same input but that is inside a component which stands couple levels "lower"?
<component1>
<component2>
<component3>
<input #someInput />
</component3>
</component2>
</component1>
Suppose, we want to get a ref to #someInput
inside component1.ts
. Is it possible?
Upvotes: 1
Views: 764
Reputation: 6424
Use @ContentChildren() decorator.
https://angular.io/docs/ts/latest/api/core/index/ContentChildren-decorator.html
Upvotes: 2