Asked by: Aliaksei Murgoa
asked in category: General Last Updated: 20th April, 2020

What are template reference variables?

A template reference variable is often a reference to a DOM element within a template. It can also be a reference to an Angular component or directive or a web component (Read more at That means you can easily access the variable anywhere in the template.

Click to see full answer.

Likewise, people ask, what is a template reference variable and how would you use it?

Template reference variables are basically used to create a reference to the input element that can be used later on in any template. It is also called the hashtag syntax because it uses a hashtag to create a reference to an element in a template.

Also, what is a template variable How would you use it? A template reference variable is a way of capturing a reference to a specific element, component or directive so that it can be used somewhere else in the same template.

In this manner, what is Template reference variable in angular 2?

Template reference variables are a very useful feature of Angular 2+ which allow you to save a reference to a DOM element or Angular Component instance. Using a reference variable on a Component will give you a reference to the actual Component instance, giving you access to all of its methods and properties.

What is ElementRef?

ElementRef is a wrapper around a native element inside of a View. It's simply a class that wraps native DOM elements in the browser and allows you to work with the DOM by providing the nativeElement object which exposes all the methods and properties of the native elements.

39 Related Question Answers Found

What do you understand by templates?

What is 2way binding?

What is Dom in angular?

What is HTMLInputElement in angular?

What is local reference in angular?

What is a template in angular?

Which feature best describes the template property?

What is #name in angular?

What is class binding in angular?

What is decorator in angular?

What is ngModel in angular?

What is metadata in angular?

How do I use angular templates?

What is module in angular?