tal*_*tal 8 casting typescript angular
我有
<input mdInput #try placeholder="Favorite food" value="Sushi">
Run Code Online (Sandbox Code Playgroud)
而且我得到了它
@ViewChild('try') myText : ElementRef;
Run Code Online (Sandbox Code Playgroud)
现在我需要得到HtmlElement函数的方法,我怎么能投出它?
并且我不希望通过这种方式添加id="try"到mdInput并通过以下方式 获取:
var cel= document.getElementById("try");
Run Code Online (Sandbox Code Playgroud)
Sar*_*ana 10
myText.nativeElement将包含对DOM元素的引用.断言myText.nativeElement为HTMLElement:
let domElement = this.myText.nativeElement as HTMLElement;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7547 次 |
| 最近记录: |