Angular 2+: Get child element of @ViewChild()

前端 未结 4 1182
[愿得一人]
[愿得一人] 2021-01-17 19:04

How can I access the child elements (here: ) of @ViewChild() in Angular 2+ without explicit declaration?

In template.htm

4条回答
  •  忘掉有多难
    2021-01-17 19:48

    HTML

    TS

     @ViewChild('parent',{static:false}) parentDiv:ElementRef
     this.parentDiv.nativeElement.firstChild
    

    You can check this out if you want do any operations in it renderer2

提交回复
热议问题