1

I'm trying to display data based on value selected in a dropdown. I need help adding an "All" option to the PrimeNG dropdown. The dropdown takes data from a json array of objects, and displays data corresponding to the object selected.

teams.json

teams: Team[] = [
{tenant: "ABC", apps:[1, 2, 3]},
{tenant: "XYZ", apps:[1, 3, 5]},
{tenant: "UVW", apps:[2, 4, 5]}
]
<p-dropdown [options]="teams" [(ngModel)]="selectedTeam" optionLabel="tenant" (ngModelChange)="onSelectChange($event)"> </p-dropdown>

So when I click ABC on the dropdown, I'm able to show the apps ABC uses and so on. When I click "All", it should show me all tenant names and apps used by each of them.

Using <select> this seems easy to do, I can just add an option like this:

<option value="all">All</option>

How do I achieve the same using p-dropdown?

I could add an object to the array with the structure { tenant: 'All', ... } but that is obviously not right. Please help!

twentyseen
  • 11
  • 2

0 Answers0