ViewChild

Gives a component a reference to an element or child in its own template.

What is ViewChild?

viewChild() (or the older @ViewChild) gives the component a reference to an element or child component in its own template, for example to focus an input.

searchBox = viewChild.required<ElementRef<HTMLInputElement>>('search');

focus() { this.searchBox().nativeElement.focus(); }

Level: Journeyman · More Angular terms at this level

Updated