Angular Template Reference Variables: A #handle for Elements

A template reference variable is a handle to a DOM element or component within your template. Use the `#varName` syntax to grab an input's value or call a child component's method. Its scope is limited to the template where it's defined.
A template reference variable is a named handle for a DOM element, directive, or component instance within your template, letting you interact with UI parts directly in the HTML. Use the `#varName` syntax to grab an `<input>`'s value for a click handler or call a child component's public method. The main footgun is trying to access this variable in your TypeScript class; it's for template-only communication. For class access, use `@ViewChild`.
Read the original → angular.dev
- #angular
- #frontend
- #templates
- #dom
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.