【发布时间】:2020-09-22 21:49:30
【问题描述】:
我可以将 ElementRef 传递给子组件,然后在那里访问其 nativeElement 吗? 我得到了 html 元素,但我无法访问 nativeElement。我可以做些什么来访问 nativeElement 或如何直接传递它?
父模板:
<tr #refTr1>
<app-cell [parentRef]="refTr1"></app-cell>
</tr>
子组件“appCellComponent”:
@Input parentRef: ElementRef;
ngOnInit(): void {
console.log(this.parentRef.nativeElement.classList);
}
【问题讨论】:
标签: angular