# 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.

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

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

Level: Journeyman · [More Angular terms at this level](https://www.ask-codey.com/glossary?category=angular&level=3)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/viewchild
