nightY772018-12-27 19:51:07
nightY77, 2018-12-27 19:51:07

Angular PrimeNG multiselect: how to programmatically select only part of the options from a list?

I have a PrimeNG multiselect, I get the options data for it from the server during initialization, the problem is that all list items are automatically selected, and I only need to select some items with certain IDs. I found a post on the Internet that you can add list items that should be selected using [(ngModel)] pushing them to the appropriate array, but my implementation does not work:

<p-multiSelect [options]="locations" [(ngModel)]="selectedItems"                                 
                                 defaultLabel="Select office"

All items in the list are selected anyway. The doc has a couple more words about the SelectItem API with similar examples, but I don’t understand how to make it work. Who knows tell me please!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question