In Angular templates, you can create a template reference variable by adding # followed by a name on an element, like #myInput on an input field. This variable holds a reference to that element or component instance. You can then use this variable inside the template, for example in event handlers, to access properties or call methods. When the template renders, Angular links the variable to the actual element. When a user clicks a button that uses this variable, Angular accesses the current state of the element, such as the input's value, and performs the action like showing an alert. The variable only exists inside the template and is not accessible in the component class. This allows easy interaction with elements directly in the template without extra code.