How do you select an element with in a component template?

Posted by Jessica Taylor | Updated on

You can use @ViewChild directive to access elements in the view directly. Let’s take input element with a reference,

and define view child directive and access it in ngAfterViewInit lifecycle hook:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers