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

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

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