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

415
Vistas
(Angular2) FormArray hide previous form as new form added

I have a form array inside a formbuilder and i am dynamically changing forms, i.e. on click load data from application 1 etc.

The issue i am having is that all the data loads in but the data in the formarray stays and just concats the old items with new.

How do I make the formarray to only have the new array and hide the previous array. i am creating an array form using angular2.

working plnkr of my project

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The following will do what you want, but as per discussed elsewhere, here is no possibility to revisit the other form elements, that requires a little more tinkering :)

Just set a condition that checks whether the object is the last item in the formArray, and if it is, it displays only that object.

So where you are iterating the objects array add the following condition:

<div *ngFor="let object of myForm.controls.objects.controls; let i=index">
 <div [formGroupName]="i" *ngIf="i === myForm.controls.objects.controls.length -1">

Add these conditions inside the formArrays in the survey tab.

Forked

Plunker

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