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

298
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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