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

343
Vistas
Change border color of a div conditionally angular

I have these two arrays :

Original Array :

$arr_1=['disappear','rising','filled','decades]; 

User Array:

$arr_2=['disappear','filled','filled','decade]; 

this.indexesAttention=[];
$arr_1.forEach(x=>{   
      //concat two arrays
       this.indexesAttention=[...this.indexesAttention,
                                    ...this.checkValue(x)]
 });

 checkValue(variable:string):number[]
 {
     
    return this.arr_2
    .map((x,index)=>x.trim()==variable.trim()?index:-1)
   .filter(x=>x!=-1) //only want the index>>-1
 }

These should return the matching indexes in this case it should return [0,2] indexes because they are matching but in my case it is returning 0,2,1,3

 [ngStyle]="(indexesAttention.indexOf(i)<0) ? {'border-color':'red','color':'red'} : show_answer === false ? {'border-color': 'black','color':'black'} : {'border-color': 'green','color':'green'}" 

Any solution to resolve this issue, Thanks

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

  arr1 = ['disappear','rising','filled','decades'];
  arr2 = ['disappear','filled','filled','decade'];

  constructor(){
    const a = this.arr2.map((e,k) => {
      const i = this.arr1.indexOf(e);
      return k == i?i:-1;
  }).filter(e => e != -1)        
    const rs = [...new Set(a)]; //output [0, 2]
  }
about 4 years ago · Santiago Gelvez 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