Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 将ElementRef从较低级别传递给子级_Angular - Fatal编程技术网

Angular 将ElementRef从较低级别传递给子级

Angular 将ElementRef从较低级别传递给子级,angular,Angular,我知道我可以使用@ViewChild获取对当前组件的某个子组件的引用: @ViewChild('someInput') someInput: ElementRef; 在HTML部分中: <input #someInput /> 但是,如果我想为相同的输入获取一个引用,但该引用位于一个“较低”级别的组件中,该怎么办 假设,我们希望在组件1.ts中获得对someInput的引用。有可能吗?使用@ContentChildren()装饰器 这可能是我正在寻找的,但我无法让它与我的

我知道我可以使用
@ViewChild
获取对当前组件的某个子组件的引用:

@ViewChild('someInput') someInput: ElementRef;
HTML
部分中:

<input #someInput />

但是,如果我想为相同的输入获取一个引用,但该引用位于一个“较低”级别的组件中,该怎么办



假设,我们希望在
组件1.ts
中获得对
someInput
的引用。有可能吗?

使用@ContentChildren()装饰器


这可能是我正在寻找的,但我无法让它与我的项目一起工作。。。它什么也找不到-查询结果为空。但我会把答案标记为正确答案,因为它肯定会解决我的问题。也许我只是用错了方法。在ngAfterContentInitAaaaaa内部使用它,我在
ngAfterViewInit
内部使用它。现在一切正常:)谢谢!!!
<component1>
   <component2>
      <component3>
         <input #someInput />
      </component3>
   </component2>
</component1>