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

294
Vistas
Rendering multiple components on tabs from array with Angular Material

I'm trying to render some components in a <mat-tab-group> from an array of components. This way:

TS

...
steps = [
    {label: "Step 1", content: [Step1Component]},
    {label: "Step 2", content: [Step2Component]},
    {label: "Step 3", content: [Step3_1Component, Step3_2Component]},
    {label: "Step 4", content: [Step4Component]},
]
...

HTML

...
<mat-tab-group>
    <div *ngFor="let step of steps;">
        <mat-tab label="{{step.label}}">
            <div *ngFor="let component of step.content;">
                <ng-container *ngComponentOutlet="component"></ng-container>
            </div>
        </mat-tab>
    </div>
</mat-tab-group>
...

All works fine, but one of my components now needs to have an MatDialog, so that component looks like this:

TS

...
@Component({
    selector: 'app-step2',
    templateUrl: './step2.component.html',
      : ['./step2.component.scss']
})
export class Step2Component implements OnInit {
    constructor(public dialog: MatDialog) { }
}
...

So I've noticed that when component's constructor has an argument (on this example, public dialog: MatDialog), my application stops working with this error:

Error: src/app/pages/home/home.component.html:40:85 - error TS2322: Type '(typeof Step1Component)[] | (typeof Step2Component)[]' is not assignable to type '((typeof Step1Component)[] & NgIterable<typeof Step1Component>) | null | undefined'.

Can someone help me fixing this? I can't find any viable solution to this.

Thanks!

over 4 years ago · Santiago Trujillo
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