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

765
Visualizações
Why is FormArray not assignable to NgIterable<any>?

I tried to pass a FormArray into a component. This component template iterates over FormArray and displays data. It allows the user to add to the array or remove items.

ChildComponent ts

@Input()
public formArray!:FormArray;

Then in the template I try:

<div class="formRow child2" *ngFor="let year of formArray; let i=index">
  List Number #{{i+1}} &nbsp; &nbsp;
  <mat-form-field class="col3 no-bottom" appearance="fill">
    <mat-label>{{ "YEAR" | translate }}</mat-label>
    <input matInput placeholder="Year" mask="0000" [formControl]="year">
  </mat-form-field>
    <button mat-flat-button color="accent" (click)="addYear()">
      <span class="material-icons">Add Year</button>

However, I get an error message:

Type 'FormArray' is not assignable to type 'NgIterable<any> | null | undefined'.
<div class="formRow child2" *ngFor="let year of formArray; let i=index">

Can anyone explain why this is happening? Highly appreciate it.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It should be

*ngFor="let year of formArray.controls;

formArray.controls is iterable

See working demo here

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