K
K
Konstantin2021-01-21 22:34:35
Angular
Konstantin, 2021-01-21 22:34:35

How to get HTMLElement in component?

There is a DOM element in the component template:

<div class="container" #main></div>

How can I get an HTMLElement reference to this element from the component?

How should I use the concept @ViewChild("main", {static: false})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GF, 2021-01-22
@Junart1

You understand correctly. Now print this to the console and see what's inside :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question