在下面的代码中
<input #myRef1 />
<input #myRef2 my-custom-attribute />
将#myRef1是ElementRef, 并且#myRef2将是MyCustomAttributeComponent指令。基本上,它隐式地找到第一个组件并将其与模板引用变量相关联。感谢 ,我可以强制执行我想要的指令/组件exportAs,但是在这里,我实际上ElementRef在这两种情况下都想要。
有什么东西可以强制#myRef2成为ElementRef 没有 TypeScript的@ViewChild(..., { read: ElementRef })。我需要在我的模板中myRef2访问ElementRef。