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

294
Views
How to deactivate one or more items in a list-box using primeng or angular2?

I am trying to deactivate one or more items according to data. For example, I have a list of cities with disable/active field, for example, and I pushed the city names in a SelectItem[] array.

NewYork, active
Rome, disable
London, active
Istanbul, disable
Paris, active

enter image description here

 this.cities.push({label:'New York', value:'New York'});
 this.cities.push({label:'Rome', value:'Rome'}); // want to disable
 this.cities.push({label:'London', value:'London'});
 this.cities.push({label:'Istanbul', value:'Istanbul'}); // want to disable
 this.cities.push({label:'Paris', value:'Paris'});

I tried to render the list-box in using primeng example

<p-listbox [options]="cities" [(ngModel)]="selectedCity"  filter="filter">
  <ng-template let-city pTemplate="item" >
        <div class="ui-helper-clearfix">
            <span >{{city.value}}</span>
        </div>
  </ng-template>      
</p-listbox>

In primeng, list-box has one attribute called disabled. If I set it then it disabled the whole list-box. But I want to disable only the specific items. Here is the implemented Plunker https://plnkr.co/edit/7MHSzdmvIWNpdHsEy4F9?p=preview

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You could always create a mutator for selectedCity...

private _selectedCity: string;
private set selectedCity(city:string) {
    if(isactive){... do stuff ...}
}

However obviously this might not be great for user experience as the item would still be clickable.

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