【发布时间】:2017-11-25 13:36:09
【问题描述】:
我正在使用Angular-cli。我有:
<div id="show"></div>
我需要在 .ts 文件中访问这个 dom 元素
document.getElementById('show') 之类的东西返回 null
【问题讨论】:
-
*我有 id="show" 的 div 块
-
使用... 并使用 @ViewChild 获取 ElementRef:stackoverflow.com/questions/36614284/…一般你应该修改模型,视图会自动更新。
标签: angular typescript