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

174
Vistas
How to select only one div at a time in angular 10

I have to create a sort filter in my application where I can select only one option at a time to sort my results. My UI is such that I can not use checkboxes. It is simple list. So I am creating the list through div. Can anyone suggest how to impleenter image description herement selection and deselection of div in angular. I can select only one div at a time. Also If I have selected any option and now i click on option 2 then option 1 div should get de-selected and option 2 div should get selected.

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

0

One solution would be to set the 'current' value when the div is clicked. Add a class when the 'current' value matches the item's value.

<div *ngFor="let item of items" 
(click)="onItemSelection(item) 
[class.current-selection]="item === currentValue">
   {{ item }}
</div>

Handle the event in your component.ts file by storing the new value:

currentValue: string;

onItemSelection(newValue: string) {
   this.currentValue = newValue;
}

Then update the look of the current item in your component.scss file:

.current-selection {
  background-color: green;
}
about 4 years ago · Santiago Trujillo 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