Angular 使用QueryList给出第一个HTML元素
我正在使用Angular 10,并尝试使用QueryList,代码如下(就像web上的许多示例一样) HTMLAngular 使用QueryList给出第一个HTML元素,angular,typescript,angular10,viewchild,viewchildren,Angular,Typescript,Angular10,Viewchild,Viewchildren,我正在使用Angular 10,并尝试使用QueryList,代码如下(就像web上的许多示例一样) HTML 一些内容 TS @ViewChild('someID')someID:QueryList; 当在组件中运行console.log(this.someIds)时,在组件初始化之后,我实际上得到的是一个ElementRef对象(可能是第一个或最后一个div),而不是整个列表 我做错了什么?将查看儿童更改为查看儿童 @ViewChildren('someID') someIds: Qu
一些内容
TS
@ViewChild('someID')someID:QueryList;
当在组件中运行console.log(this.someIds)时,在组件初始化之后,我实际上得到的是一个ElementRef对象(可能是第一个或最后一个div),而不是整个列表
我做错了什么?将查看儿童更改为查看儿童
@ViewChildren('someID') someIds: QueryList<ElementRef>;
@ViewChildren('someID')someID:QueryList;
将“@ViewChild('someID')”更改为“@ViewChildren('someID')”@Andrei谢谢!!
@ViewChild('someID') someIds: QueryList<ElementRef>;
@ViewChildren('someID') someIds: QueryList<ElementRef>;