Yesterday’s journal uses the same example as below but uses required and the template reference #search is removed, which means when onSearch is called, there will be an error similar to this: RuntimeError: NG0951: Child query result is required but no value is available. Find more at https://angular.dev/errors/NG0951. This helps enforce the existence of the element.
<input placeholder="Search for something" (keyup.enter)="onSearch()" />
import { viewChild } from '@angular/core';
searchInput = viewChild.required<ElementRef>('search');
onSearch() {
const query = this.searchInput()?.nativeElement.value;
console.log('search query', query);
}