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

855
Views
Angular: How to hide PrimeNG drop-down selected option?

I need my p-dropdown to hide the previously selected option.

For example, I have options A, B, and C. If I previously selected A, only B and C should show up in the dropdown list. Then if I select B, now only A and C should show up.

//component.ts
this.planOptions = [
  { name: 'A'},
  { name: 'B'},
  { name: 'C'}
]; 
//component.html
<p-dropdown id="plan_option"
  [options]="planOptions
  [(ngModel)]="selectedPlanOption"
  optionLabel="name">
</p-dropdown>       
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should create a copy of planOptions that contains only the possible options

TS File

copyOfPlanOption = planOption;
chosenOption: 'A';
const index = copyOfPlanOption.indexOf(chosenOption);
if (index > -1) {
  copyOfPlanOption.splice(index, 1);
}

HTML File

 <p-dropdown [style]="{'minWidth':'100%', 'width': '100px', 'height':'50px'}" id="plan_option" appendTo="body" [options]="copyOfPlanOption" [(ngModel)]="selectedPlanOption" placeholder=" "  optionLabel="name"></p-dropdown>       
about 4 years ago · Juan Pablo Isaza 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!