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

411
Views
(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 answers
Answer question

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