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

121
Views
Retrieve updated array values when the same array is updated with different condition

I want to display a dropdown value based on selection of type in another dropdown in angular Basically I have an array of values which I will filer it on the based on type selected which is working fine. below is the code of filtering.

filterMethod(){
if(type === 'P'){
    this.filteredArray = this.relationArray.filter(ele=> this.personValue.includes(ele.name));
  } else{ 
    this.filteredArray = this.relationArray.filter(ele=> this.orgValue.includes(ele.name));
  }
}

And in HTML I'm looping it.

<mat-select formControlName="relation" aria-owns="relationshipSelect">
  <mat-option *ngFor="let rel of filteredArray" [value]="relation.name">
    {{rel.value}}
    ............

This above HTML is basically a child component where user can multiple dropdown when clicked new button. i.e., another dropdown will come next to it and so on...

Here what is happening is after selecting the relation dropdown when user click new button another relation dropdown is coming but the existing relation dropdown value is vanished. If user fires the filterMethod() method the vanished value will come.

I suspect it is because of calling new button new instance will be created and array will be set to its original state.

about 4 years ago · Santiago Gelvez
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!