【发布时间】:2021-05-01 17:00:38
【问题描述】:
我正在尝试像这样使用 ViewChild:
@ViewChild('hello', { static: false })
divHello?: ElementRef;
这是模板:
<div class="wrap" #hello>
Some test data
</div>
但是,ViewChild 注释显示此错误:
Unable to resolve signature of property decorator when called as an expression.
This expression is not callable.
Type 'void' has no call signatures.
制作目标 ES5 不是我的解决方案,因为我不希望这样。
有什么方法可以使用 ViewChild 吗?我指的是这个教程:https://www.tektutorialshub.com/angular/renderer2-angular/
【问题讨论】:
-
请始终关注 angular.io angular.io/api/core/ViewChild的最新文档
标签: angular viewchild angular-renderer2 elementref