gpt4 book ai didi

javascript - Angular,获取 ElementRef

转载 作者:行者123 更新时间:2023-11-28 16:48:00 26 4
gpt4 key购买 nike

我需要在子节点中获取ElementRef。

我的模板

<div #charts *ngFor="let tag of _tags">
<jqxBulletChart
style="margin-left: 10px; float: left;"
[width]='50'
[height]='350'
[barSize]='"35%"'
[labelsFormat]='"c"'
[title]="''"
description="{{tag.configuration.name}}"
[showTooltip]='true'
[labelsFormatFunction]="labelsFormatFunction"
[tooltipFormatFunction]="tooltipFormatFunction" [ticks]='ticks'
[ranges]='tag.value'
[pointer]='pointer'
[orientation]="'vertical'"
>
</jqxBulletChart>
</div>

我调用

@ViewChildren('charts') infoCharts: ElementRef;

并获取 child

for (let chart of this.arrCharts) {
console.log(chart);
console.log(chart.nativeElement.lastChild)
let child: jqxBulletChartComponent = chart.nativeElement.lastChild;
console.log(child);
console.log(+this.tags[count].displayValue);
child.val(+this.tags[count].displayValue || 0);
// child.val(20);
count++;
}

但我的“ child ”应该是 ElementRef 类型,我不知道该怎么做

最佳答案

请尝试下面的代码,它将为您提供 jqxBulletChart 的 ElementRef

@ViewChildren(jqxBulletChartComponent,{read: ElementRef}) hellos: QueryList<ElementRef>;

请注意,您需要提供 JQXBulletChartComponent 并且必须将 viewChildren 读取为 ElementRef。

请告诉我它是否适合您。

祝你编码愉快!!!

关于javascript - Angular,获取 ElementRef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60303910/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com