【发布时间】:2021-06-08 03:27:45
【问题描述】:
我使用 Angular 9 并使用 ViewChild 和 ViewChildren 来选择我的 HTML 文件中存在的元素。这两个函数中的任何一个都支持类选择器吗?据我所知,它们仅适用于 ID。
@ViewChild('.foo') Foo: ElementRef;
任何替代方案也很好,只是在执行函数期间我想访问所有“Foo”对象。
https://angular.io/api/core/ViewChild
https://angular.io/api/core/ViewChildren
谢谢!
【问题讨论】:
-
你想达到什么目的?
-
我想通过类选择器获取HTML元素S的
nativeElement。我认为 ViewChild/ViewChildren 可以帮助我
标签: angular