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

106
Vistas
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 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