Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
How does TemplateRef and ViewContainer differ in Angular 2

From my understanding of docs and few sample code, I realize that ViewContainer is something that holds a templateRef, while templateRef in itself holds the HTML. But I would like to know a further explanation:

I have questions like :

  1. What each one of them exactly does.

  2. How often do we find each one of them in a layout. Is each of them associated with every single node on my HTML.

  3. Has it something to do with routing as well

Thanks in advance

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Template Ref                            ViewContainerRef
-----------------------------------------------------------------------------------     
Represents an Embedded Template         It is a continaer in which templates in
                                        which one or more Views can be attached

Used for creating a custom structural   Wrapper for holding the view
directive                               created using TemplateRef

Two ways to access                      Can attach views in 2 ways
   - using * infront                         - using createComponent()
   - using as a property binding             - using createEmbeddedView()

To answer your second question,

  • We don't have a practice of creating structural directives.
  • So, mostly we will not use it often.
  • However, the structural directives which we use ngIf, ngSwitch, ngFor are creating using these classes.
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda