2
我想要使用模板引用變量來獲取對Angular 2模板中的組件的DOM元素的引用。這適用於普通的html標籤,但在組件上有不同的行爲。例如在組件上訪問帶有模板引用變量的DOM元素
<!--var1 refers to the DOM node -->
<div #var1></div>
<!--var2 refers to the component but I want to get the DOM node -->
<my-comp #var2></my-comp>
有什麼辦法強制模板引用變量引用DOM節點,即使它在組件上?如果是這樣的話,它在任何地方的文檔涵蓋?我能找到的唯一文檔是https://angular.io/docs/ts/latest/guide/template-syntax.html#!#ref-vars,他們沒有詳細說明變量是如何解決的。