ngSelect select all values by default

47 views Asked by At

I programmed a filter in Angular. As default I would like to select all options. At the moment my HTML looks like that

<ng-select [items]="categoryFolders"
           [multiple]="true"
           bindLabel="folderId"
           bindValue="folderId"
           placeholder="Filter..."
           [closeOnSelect]=false
           [(ngModel)]="selectedItem"
           (ngModelChange)="changedSelectedItems(selectedItem)">
</ng-select>

if I set the selectedItem value inside the typescript to categoryFolders. It gives me an error:

ng-select-ng-select.mjs:1942 Setting object({"folderId":"xxx"}) as your model with bindValue is not allowed unless [compareWith] is used.

where do I have to use the [compareWith] keyword? Do i have to do something else?

My items only have 1 value and that is a string, that serves as id and value.

If this is a repost, please point me to the original.

0

There are 0 answers