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

122
Visualizações
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
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