2
Reply

What is template reference in Angular?

Kirtesh Shah

Kirtesh Shah

3y
1.2k
1
Reply

What is template reference in Angular?

    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.

    Good sharing in here!
    slope game