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

109
Visualizações
Put projected Angular content into a component through routing

In a context of a micro-front-end application I have a projected content in the app.module.ts that I want to put in a component that was instantiated via the router.

Here is a solution that does not work:

  1. I referenced the projected content as follow
  <ng-template #projected>
    <ng-content></ng-content>
  </ng-template>

  <router-outlet></router-outlet>
  1. I set the reference in a service
@ViewChild('projected', { static: true }) templateRef: TemplateRef<unknown>;
// ...
this.service.projectedRef = templateRef;
  1. use it in the component that was created by the router
 <ng-container [ngTemplateOutlet]="service.projectedRef"></ng-container>

Any idea why doesn't that work and how I can solve this problem?

Note: when I use <ng-container [ngTemplateOutlet]="service.projectedRef"></ng-container> inside the app.component.html, it works fine, but not inside the routed component.

about 4 years ago · Juan Pablo Isaza
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