Angular · Junior · Question 15 of 75
What is a template reference variable #nameInput?
<input #nameInput />
<button (click)="greet(nameInput.value)">Greet</button>- ✓Correct answer: A reference to the element (or component/directive) that can be used elsewhere in the template
- 2A CSS id selector for styling the input
- 3A two-way binding to a component field called
nameInput
Explanation
#ref on a DOM element points to that element; on a component it points to the component instance. The variable is available in the template only; in the class you use viewChild() to get a reference.