Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda