Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

763
Views
¿Por qué FormArray no se puede asignar a NgIterable<any>?

Traté de pasar un FormArray a un componente. Esta plantilla de componente itera sobre FormArray y muestra datos. Permite al usuario agregar a la matriz o eliminar elementos.

ChildComponent ts

 @Input() public formArray!:FormArray;

Luego en la plantilla intento:

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

Sin embargo, recibo un mensaje de error:

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

¿Puede alguien explicar por qué ocurre esto? Lo aprecio mucho.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Debería ser

 *ngFor="let year of formArray.controls;

formArray.controls es iterable

Ver demostración de trabajo aquí

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!