What is the scope of the template reference variable in Angular?

Discussão em 'Angular' iniciado por Sasuke Uchiha, Junho 26, 2025.

  1. What is the scope of the template reference variable in Angular?

    I can not find a clear answer to my question in documentation. Even though empirically I can say that the whole template can access the template reference variable.

    1 Is it the case? Is the template reference variable guaranteed to be accessible in the whole template?

    2 Or is the template reference variable accessible only in the child and sibling elements of the element which is referenced by the template reference variable?

    Over here I found the following statement:


    Use template variables to refer to elements — The newHero template variable refers to the <input> element. You can reference newHero from any sibling or child of the <input> element.
    ​

    Does it mean that only the 2 is guaranteed by Angular?

    Continue reading...

Compartilhe esta Página