What is template reference in Angular?
What is template reference in Angular?
Good sharing in here!
slope game
Tempelate refrence variable is used to refer the DOM Element and we can declare the variable with # symbol.
Example.
input #phone placeholder=”phone number”
In the above example # phone is used as reference template.
Angular assigns each template reference variable a value based on where you declare the variable:
If you declare the variable on a component, the variable refers to the component instance.
If you declare the variable on a standard HTML tag, the variable refers to the element.
If you declare the variable on an
If the variable specifies a name on the right-hand side, such as #var=”ngModel”, the variable refers to the directive or component on the element with a matching exportAs name.