Kirtesh Shah
What is template reference in Angular?

What is template reference in Angular?

By Kirtesh Shah in Angular on Dec 30 2021
  • Venkatesh Mahendru
    Jan, 2022 3

    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 element, the variable refers to a TemplateRef instance, which represents the template.
    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.

    • 1
  • sarah roxon
    Sep, 2022 15

    Good sharing in here!
    slope game

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS