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

412
Visualizações
(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 Respostas
Responde à pergunta

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